像
select case when max(t1.age) > 60 then 'RED' else 'GREEN' end table1_age,
case when max(t2.age) > 60 then 'RED' else 'GREEN' end table2_age,
case when max(t3.age) > 60 then 'RED' else 'GREEN' end table3_age
from (select max(age) age from table1) t1
cross join (select max(age) age from table2) t2
cross join (select max(age) age from table2) t3;
或
select 'table 1' tabl,
case when max(age) > 60 then 'RED' else 'GREEN' end
from table1 t1
union all
select 'table 2' tabl,
case when max(age) > 60 then 'RED' else 'GREEN' end
from table2
union all
select 'table 3' tabl,
case when max(age) > 60 then 'RED' else 'GREEN' end
from table3;
情況下,當最高(年齡)> 60,然後 '紅' 其他情況下,當最高(年齡)< 30然後'GREEN'結束 是否有可能在第二個標準之間或第三個之間的其他標準之間,因爲我已經在上面做了?我上面發佈的語法是錯誤的。 – Deprecated
@ user1821973當然是。你的錯誤是你在別的時候。你只需要什麼時候。其他的就是「全部」。例如,當最大(年齡)> 60時,則...當最大(年齡)在30和60之間時,則...等等,並在末尾有可選的「其他」。 – DazzaL
太棒了!這工作,謝謝。 – Deprecated