Let's say I have a table T
, that has one attribute, A
, an integer.
How can I make the SQL query return MAX(T) + 1
if T
contains a 5 and MAX(T) + 2
if it doesn't?
Let's say I have a table T
, that has one attribute, A
, an integer.
How can I make the SQL query return MAX(T) + 1
if T
contains a 5 and MAX(T) + 2
if it doesn't?
SELECT MAX(a) + CASE WHEN (5 IN (SELECT a FROM t)) THEN 1 ELSE 2 END AS max_plus_something FROM t