标签: mysql sql
我有一些原始数据,如图片1
可以进行查询并显示如下图2所示的数据
我不知道如何进行查询以使结果显示在第2号图片中,有人可以帮助我解决这个问题吗?
图片1
图片2
谢谢
答案 0 :(得分:0)
用例何时
select user, max(case when data='on' then date end )as start, max( case when data ='off' then date end) as end from t group by user