Relative Content

Tag Archive for sqlsql-serversqlite

SQL SERVER – How do I delete refunded invoices from customer invoices?

I would like to get the following output from the table below: For each customer, the refunded invoices will be removed from the purchased invoices. For example, if a single product is purchased and the same product is refunded, both rows (invoices) will be deleted. However, if 2 products are purchased in a single invoice and one of them is returned, only the refunded invoice will be removed from the table by deducting the refund amount and income (refund invoice) from the invoice containing these 2 product information. I have marked purchased invoices and refunded invoices in the same color.