Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Issue on forming a query

Author  Topic 

sridhar3004
Starting Member

34 Posts

Posted - 2011-01-31 : 00:06:34
I've the following data

ProductMaster
P1
P2
P3

CategoryMaster
1 P1 c1
2 P1 c2
3 P2 c1
4 P2 c2
5 P3 c1
6 P3 c2

TicketMaster
ID CategoryMaterID Status
1 1 Open
2 2 Closed
3 3 Pending

I want an output that gives me productwise, categorywise, count of statuses
In the example I mentioned above, the output will be
Product 1
Category 1
Open Closed Pending
1 0 0
Category 2
Open Closed Pending
1 0 0

and so on......



Any answers will be highly appreciated

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-15 : 15:14:40
I want an output that gives me productwise, categorywise, count of statuses

Select Product.productID,Category.CategoryID,count(OtherTable.Statuses) as CountOfStatuses
From Product
Inner join Category on Product.ProductId=Category.CategoryID
Inner join otherTable on OtherTable.CategoryId=Category.CategoryID
Group by Product.productID,Category.CategoryID
Go to Top of Page
   

- Advertisement -