I have a table order_status
| id | order_no | seq_no | status | 
|---|---|---|---|
| 1 | 123 | 1 | order received | 
| 2 | 123 | 2 | order processing | 
| 3 | 456 | 1 | order received | 
| 4 | 789 | 1 | order received | 
| 5 | 789 | 2 | order processing | 
| 6 | 789 | 3 | order completed | 
I want to get the status of the max seq_no of each order_no.
That is:
| id | order_no | seq_no | status | 
|---|---|---|---|
| 2 | 123 | 2 | order processing | 
| 3 | 456 | 1 | order received | 
| 6 | 789 | 3 | order completed | 
I have tried:
select * from order_status where id IN 
(select id from order_status where max(seq_no) group by order_no)
But oracle db does not recognize the statement. There is an error at group by.
Please help. Thanks.
 
    