我正在使用PostgreSQl,这是我在数据库中的表格:
如何编写一个给我这个结果的查询:
答案 0 :(得分:0)
或者您可以编写像
这样的查询select id_salarie,
max(case when date_pointage = '2015-01-01' then round(nb_heures::numeric,2) else null end) as "2015-01-01",
max(case when date_pointage = '2015-01-02' then round(nb_heures::numeric,2) else null end)as "2015-01-02",
max(case when date_pointage = '2015-01-03' then round(nb_heures::numeric,2) else null end) as "2015-01-03"
from my_table where id_salarie = 1
group by id_salarie;
查询看起来巨大而可怕但适用于多维数据集