How to get value in one row in postgreSQL?
问题 I have database table name emp_leave in postgreSQL9.3 like |emp_name|department|ann_leave|med_leave|cas_leave|org_ann_lv|org_med_lv|org_cas_lv| | Tame | IT | | | 3 | | | 25 | | Tame | IT | 4 | | | 20 | | | | Tame | IT | | 3 | | | 30 | | I want the query result like |emp_name|department|ann_leave|med_leave|cas_leave|org_ann_lv|org_med_lv|org_cas_lv| | Tame | IT | 4 | 3 | 3 | 20 | 30 | 25 | 回答1: You want aggregation : select el.emp_name, el.department, max(el.ann_leave), . . . , max(el.org_cas