[Resolved] SQL Query v9
Posted: 03 Jun 2010, 14:18
Hi
I have the following table structure :
I need to a query to get this resultset :
The furthest I could get is
which gives me each ParentObjectID, with the Status, and the number of rows per Status, i.e. from the example this would be
Can anyone help?
I have the following table structure :
Code: Select all
ParentObjectID ObjectID Status
-------------- --------- ------
1 1 1
1 2 1
1 3 2
1 4 2
1 5 3
2 6 1
Code: Select all
ParentObjectID Status1Count Status2Count Status3Count
1 2 2 1
2 1 0 0
Code: Select all
SELECT ParentObjectID, Status, count([Status]) AS [StatusCount] FROM MyTable GROUP BY [Status], ParentObjectID
Code: Select all
ParentObjectID Status StatusCount
1 1 2
1 2 2
1 3 1
2 1 1