简体   繁体   中英

PostgreSQl: select multiple rows and make it in one row

I'm using PostgreSQl and this is my table in database:

在此处输入图片说明

how can I write a query that gives me this result :

在此处输入图片说明

or you can write query like

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;

Query looks huge and terrible but works for cubes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM