Group by and order by in the same query
I need to fetch the results from a table using group by and order by in the same query. Basically I need to fetch the latest transaction from the transactions table based on two columns i.e. latest row based on unique combination of two columns.
I need to fetch the latest row grouped by two columns.
Eg: I have a table transactions which contains the transactions of the quotations of a request Columns are:
- Quote Id
- Payment Type (Advance Payment, Full Payment, Vendor Payment)
I need to get the latest transaction on the basis of Quote Id and Payment Type as there may be several transactions of a quotation but the latest one is success. So, I need to fetch the latest transaction which was success for the quote and payment type - Vendor Payment.
Please or to participate in this conversation.