Last post Aug 17, 2016 04:59 PM by kmcnet
Aug 16, 2016 01:53 AM|kmcnet|LINK
Hello everyone and thanks for your help in advance. I need to write a query against a table tblProductPayments that returns each distinct ProductCode like:
Select Distinct ProductCode from tblProducts
Then return the MAX PaidAmt from the same table for each ProductCode. I'm not sure how to do this. Any help would be appreciated.
Aug 16, 2016 05:53 AM|eralper|LINK
We can use
SQL aggregate functions with Partition By clause as follows
MAX(PaidAmt) OVER (Partition By ProductCode) MaxPaidAmt
This will enable you to list products and maximum paid amount on product bases
I hope it helps,
Aug 16, 2016 01:26 PM|limno|LINK
MAX(PaidAmt) as MaxPaidAmt
Group by ProductCode
Aug 17, 2016 04:59 PM|kmcnet|LINK
Perfect. Exactly what I needed. Thanks.