Closed. This question needs to be more focused。它目前不接受答案。
想改进这个问题吗?更新问题,使其只关注一个问题editing this post
10个月前关闭。
我有一张桌子
mss | circle |  psr  |   date
-----+--------+-------+----------
 m1  | mum    |  99.6 | 20190211
 m2  | mum    |  98.6 | 20190211
 m3  | mum    |  97.6 | 20190211
 m1  | mum    |   9.6 | 20190212
 m2  | mum    |  93.6 | 20190212
 m3  | mum    |    46 | 20190212
 m1  | mum    |  9.36 | 20190213
 m2  | mum    | 99.36 | 20190213
 m3  | mum    | 29.36 | 20190213

需要输出为
enter image description here

最佳答案

使用条件聚合

select mss,circle, max(case when date='20190211' then psr end) date11th,
max(case when date='20190212' then psr end) date12th,
max(case when date='20190213' then psr end) date13th
from table group by mss,circle

关于sql - 以下问题需要SQL查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54683677/

10-13 06:10