Skip to content
Advertisement

Display total where row number is max row_number

I have a query that displays invoice information, and in final column displays the Supplier’s total balance, I only want the total to be displayed on the last line of that supplier’s invoice entries.

ie. the results may contain 100 invoices for say 20 suppliers, each supplier having a different number of invoices, the Account_Total should only be displayed on the final row for that particular pt_account. (row_number is the MAX value for that pt_account.)

When I attempted, I got a windowed error.

Advertisement

Answer

You can use a case expression. In addition, a subquery is not needed. You can use window functions:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement