postgres - group by on multiple columns - master/detail type table
- by smpillay
I have a table order(orderid, ordernumber, clientid, orderdesc etc.,) and a corresponding status for that order on an order_status table ( statusid, orderid, statusdesc, statusNote, statustimestamp)
say I have a record in order as below
orderid orderumber clientid orderdesc
1111 00980065 ABC blah..blah..
and a corresponding status entries
statusid orderid statusdesc statusNote statustimestamp
11 1111 recvd status blah yyyy-mm-dd:10:00
12 1111 clientproce status blah yyyy-mm-dd:11:00
13 1111 clientnotice status blah yyyy-mm-dd:15:00
14 1111 notified status blah yyyy-mm-dd:17:00
How can I get the following result (latest timestamp along with multiple columns)
1111 14 00980065 ABC blah..blah.. notified status blah yyyy-mm-dd:17:00