I have a problem, I’ve spent a lot of time on. I have to display the pairs of items (Item1, Item2, How many) that appear on the invoices – and how many pairs have repeated. The table that connects invoices to goods is called "Transactions".
I Have 3 tables:
Items: IdItem, Name
Transactions: IdTransaction, IdInvoice, IdItem
Invoices: IdInvoice
Result of SQL Query must be:
Item1 | Item2 | Number
2
Answers
Assuming your tables look like this:
If this is true then you need to query the results like this:
This sounds like a self-join and aggregation: