Skip to content
Advertisement

Return opposite transaction value rows

I have this table structure and I want a query that needs to be returning opposite side columns values.

If I pass parameter with value Overtime then it should return following rows

The logic is against each transaction if the selected Account is on Debit side it should print the Credit side accounts and if the selected Account is on Credit side it should print Debit side accounts against that specific TransactionCode

Advertisement

Answer

The following code gives the desired result. It does that by checking to see whether the provided parameter is a debit or credit (or doesn’t exist) in the current transaction, then only displays the reverse as specified.

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