var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Select When/Then?
I'm trying to complete a query.
I have two numeric columns.
If a is larger than b I want it to return 'Over'
when a is less than b I want it to return 'Under'
when they're even I want it to return 'even'
Something Like this...
How can I use WHEN in a Select clause to do this? (Or can this type of query not be done?)
Select When ColA > ColB Then 'OVER' ElseIf colA<ColB Then 'Under' Else 'even', FirstName, Position, from Table
SELECT CASE WHEN COl1>COl2 THEN 'Over' ELSE 'Under' END
for above u can write the query as below
select "Status" =
when ColA>ColB then "over"
when colA<ColB then "under"
end, FirstName, Position from Table
Now, you job is to tell me why I'd do such a silly thing (yes, there is a reason).
WHEN colA = colB THEN 'Even'
WHEN colA < colB THEN 'Under'
WHEN colA > colB THEN 'Over'
ELSE 'Not comparable!'
END AS Status
I guess you are considering NULL Values
Am I right?
Correct, NULL values are the most likly form of non-comparable items.