【发布时间】:2015-01-26 23:33:46
【问题描述】:
我有一个mysql表是这样的
ID status1 status2 status3 status4 date
1 busy null callagain null 2014-11-28
2 null null busy null 2014-11-26
3 notreachable busy null null 2014-11-26
其中 ID 是主键。 我想从status1,status2,status3,status4列中获取一行中最后一个非空值的列名,结果是这样的
ID status
1 status3
2 status3
3 status2
我还需要一个带有此查询的 where cluase,其中此结果状态 ='any_value'。 请帮帮我。
【问题讨论】:
标签: mysql sql select case conditional-statements