mardi 4 août 2015

SQL - Knocking off Accordingly

I have an issue in SQL where all transaction just come into one giant messy tables.

Example:

1 | Invoice | $300
2 | Invoice | $250
3 | Payment | $100
4 | Invoice | $200
5 | Payment | $300

So i will have 3 invoices and 2 paymentsbut

the Payment at line 3 can only be knocking off the Invoice on line 1 and Payment on line 5 is for the Invoice in line 2.

I want to Net Off the Payment and Find rather it is an Overpayment or Underpayment or it is knocking off entire invoice.

How can i do this?

Aucun commentaire:

Enregistrer un commentaire