postgres - group by on multiple columns - master/detail type table
Posted
by smpillay
on Stack Overflow
See other posts from Stack Overflow
or by smpillay
Published on 2010-05-21T19:27:52Z
Indexed on
2010/05/21
19:30 UTC
Read the original article
Hit count: 188
postgresql
|group-by
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
© Stack Overflow or respective owner