samedi 11 avril 2015

Need help on grouping this SQL table


Vote count:

0




I have this table


enter image description here


I want to group it like



ProductID Purchased Sold
------------------------------------
1 235 0.00
2 125 0.00
3 55 24.00


Here Purchased = (IsCreditor = 0)


I tried this



SELECT
ProductID,
Max (TotalQty) As Purchased,
Min(TotalQty) As Sold
FROM
TestTable
GROUP BY
ProductID


It will work only if a product have both IsCreditor = 0 and IsCreditor = 1



asked 27 secs ago

Sayka

1,230






Need help on grouping this SQL table

Aucun commentaire:

Enregistrer un commentaire