FAQ Database Discussion Community


How to create a sequence on selected values in MySQL?

mysql,sequence,case-statement,nextval
I'm trying to create a query which will select a team from a declared variable and then make the remaining teams "anonymous" by giving them generic brands and sequential IDs. For example, if my dataset has 3 different team names (ABC, DEF, and GHI), but I would only like the...

Is There Anything Like a Templatized Case-Statement

c++,templates,conditional,case-statement,nested-if
So I have this really ugly code: template <typename T> std::conditional_t<sizeof(T) == sizeof(char), char, conditional_t<sizeof(T) == sizeof(short), short, conditional_t<sizeof(T) == sizeof(long), long, enable_if_t<sizeof(T) == sizeof(long long), long long>>>> foo(T bar){return reinterpret_cast<decltype(foo(bar))>(bar);} I'm using nested conditional_ts to make a case-statement of sorts. Is there something out there that accomplishes this more...

Apply rank using RowNumber based on multiple conditions

sql,sql-server,rank,case-statement,rownumber
Looking for some suggestions here on a project that I am currently working on. I have a table that consists of Vehicle Name Number of Contracts Sale Amount Ratio I would like to add a Row Number to the table based on certain criteria. IF there are 5 or more...

Bash case statement restart on invalid input

bash,case-statement
Trying to figure out a way to return in a case statement. For example, if you run this.... while : do clear cat<<-EOF ====================== Foo Bar Doo Dah Setup ====================== (1) Foo (2) Bar (q) Quit ---------------------- EOF read case $REPLY in "1") foo="foo" ;; "2") bar="bar" ;; "q") break...

Using CASE and LIKE to evaluate - logic issues

sql-like,case-statement,proc-sql
Unfortunately I am not a coder…I have used CASE statements before but not in combination with "LIKE". I'm not sure if my issues have to do with CASE or something else. I am using proc sql (SAS) to identify cases that have purchased specific products as defined by the COMPANY...

SQL Case Statement - If first 'when' returns null then complete the 2nd when

sql-server,null,case-statement
Just wondering if anyone can help me , I am running a case statement that references a different table. It needs to look up the make, model and year of a car as well as the position (FL,FR,BL,BR) and return the kit number. Up to 4 entries can exist in...

Bash Script to let user choose from a list or enter their own

bash,variables,case-statement
I have a simple script which i want to list some pre-filled choices or for the user to enter a number to correlate with a build This is what I have currently. read -p "Please select from the list below or enter the build number you would like to download...

Scala sum of all elements in the leaves of a tree using pattern matching

scala,tree,sum,pattern-matching,case-statement
I'm learning Scala by working the exercises from the book "Scala for the Impatient". One of the questions asks: /** * Q5: One can use lists to model trees that store values only in the leaves. For example, the list ((3, 8) 2 (5)) * describes the tree * ....

How to restart or reuse a case statement in Ruby?

ruby,loops,refactoring,case-statement
After going through the codecademy ruby section "A Night at the Movies", I wanted to extend the case-statement to allow input again. By the end my code was: movies = { living_torah: 5, ushpizin: 5 } def input #method for gets.chomp gets.chomp.downcase end puts "To exit please type 'Quit' or...