I have a table with 2 columns (db: sql server 2008):
id name
----- ------
1 Bob
2 Mike
3 Mary
4 Mike
5 Barry
6 Benson
7 Burrows
I want to get a count of names that start with B and start with M (in one row)?
Like:
Count of B Count of M
----------- ------------
4 3
The only thing that comes up for me is a union. Any ideas to do it cleaner in a single query (no union)?
Try it by using
CASE,SQLFiddle Demo