1.动态决定输出,
select case
when red1%7=0 or red2%7=0 or red3%7=0 or red4%7=0 or red5%7=0 or red6%7=0 then 7
when red1%9=0 or red2%9=0 or red3%9=0 or red4%9=0 or red5%9=0 or red6%9=0 then 9
when red1%11=0 or red2%11=0 or red3%11=0 or red4%11=0 or red5%11=0 or red6%11=0 then 11
else term
end as result,rowid,count(*)
from _DBHISTORY group by result
2.标准switch case
select column_value case
when 1 then 1
when 2 then 2
else
3
end as result,rowid
from tableName