SELECT model
, make
, COUNT(CASE WHEN location = 1
THEN location END ) AS Count1
, COUNT(CASE WHEN location = 2
THEN location END ) AS Count2
, COUNT(CASE WHEN location = 3
THEN location END ) AS Count3
FROM daTable
GROUP
BY model
, make

Incredible! The more I learn about SQL the more amazed I am. BTW your simply-sql.com site does not have any links on it to purchase your book (unless I missed something... I don't see any links at all just a static page), I do see it on Amazon though, I will definitely buy it on Amazon unless you have a direct way to buy. Thanks for your help!

Originally Posted by r937

Code:

SELECT model
, make
, COUNT(CASE WHEN location = 1
THEN location END ) AS Count1
, COUNT(CASE WHEN location = 2
THEN location END ) AS Count2
, COUNT(CASE WHEN location = 3
THEN location END ) AS Count3
FROM daTable
GROUP
BY model
, make