Skip to content
Advertisement

Tag: case

Problems with Postgresql CASE syntax

Here is my SQL query: When I execute the above query, I get this error: ERROR: CASE types record and integer cannot be matched From the error message I understand that PostgreSQL take the second select, respectively elapsed_time_from_first_login as a row, even if it will always be a single value (because of the min() function). Question: do you have some

Mysql SELECT CASE WHEN something then return field

I have two field nnmu and nnmi , and reverse, At first everything looks good, but somehow it mix up values, it work when nnmi and nnmu both are equal to 0, but when either value is 1 it returns nonsense. Any help? Answer You are mixing the 2 different CASE syntaxes inappropriately. Use this style (Searched) Or this style

Dynamic order direction

I writing a SP that accepts as parameters column to sort and direction. I don’t want to use dynamic SQL. The problem is with setting the direction parameter. This is the partial code: Answer You could have two near-identical ORDER BY items, one ASC and one DESC, and extend your CASE statement to make one or other of them always

Advertisement