I have data in SQL server 2005 table similar to below format.
OrderNo ProductId Sale
----------------------
1 A £10
2 B £20
3 C £30
4 A £10
4 B £20
5 A £10
5 B £20
6 C £30
6 B £20
7 C £30
I need to write TSQL query that would give me result table in this format.
NoOfOrders 'A' SaleValue 'B' SaleValue 'C' SaleValue
------------------------------------------------
Prod A (Only) 1 £10
Prod B (Only) 1 £20
Prod C (Only) 2 £60
Prod A & B 2 £20 £40
Prod A & C 0 £0 £0 £0
Prod B & C 1 £20 £30
Any idea greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire