I have this table that has 2 columns:
ID, TypeID
Each ID can have multiple TypeIDs. In the query result i want to have the following:
ID, Count(TypeID = 10), Count(TypeID = 20 or 30), Count(TypeID 40 and 50)
The query itself should be as fast / performant as possible. Can anyon help?
Try this:
For the last case:
Count(TypeID 40 and 50)I think the predicateTypeID IN (40, 50)will work for you, since it will give the count of values 40 and 50.SQL Fiddle Demo