2021年1月26日星期二

postgree group by order by query

i have database

kode    wilayah        area  001 | Wilayah 1     | Area Padang  002 | Wilayah 2     | Area Bandung  006 | Wilayah 3     | Area Bandung  008 | Wilayah 4     | Area Bogor  004 | Wilayah 5     | Area Jakarta  

In the table above there is an area for 'Bandung' which is the same with a different code. how to make groupings area, and when grouping displays the area 'Bandung' with code 006

I made it like this but the postgree error

SELECT * FROM tbl_area   GROUP BY area  ORDER BY kode DESC  

how to make a result like this

kode    wilayah        area  001 | Wilayah 1     | Area Padang  006 | Wilayah 3     | Area Bandung  008 | Wilayah 4     | Area Bogor  004 | Wilayah 5     | Area Jakarta  
https://stackoverflow.com/questions/65912471/postgree-group-by-order-by-query January 27, 2021 at 11:21AM

没有评论:

发表评论