SQL query mixing aggregated results and single values
- by Paul Flowerdew
I have a table with transactions. Each transaction has a transaction ID, and accounting period (AP), and a posting value (PV), as well as other fields. Some of the IDs are duplicated, usually because the transaction was done in error. To give an example, part of the table might look like:
ID PV AP
123 100 2
123 -100 5
In this…