I need someone to help me with some formatting. I have tried to get this into a Row using subqueries and UNION ALL etc with no success. It would seem to be rather easy but I am just beating my head against a wall with this. The table is laid out like so with data:
Date    pTypeCode   Location    Amt
1/1/2015    C   Store1  50.21
1/1/2015    C   Store1  125.62
1/1/2015    P   Store 1 250.1
1/1/2015    EB  Store 1 125.01
1/1/2015    C   Store 2 50.25
1/1/2015    C   Store 2 100.25
1/1/2015    EB  Store 2 125.25
1/3/2015    EB  Store 1 35.25
1/3/2015    C   Store 1 35.25
1/3/2015    C   Store 1 35.25
1/3/2015    P   Store 1 35.25
1/3/2015    C   Store 2 85.15
1/3/2015    C   Store 2 65.25
1/3/2015    P   Store 2 65.25
1/3/2015    EB  Store 2 65.25
What I need it to get counts of pTypeCode as columns per row. I can easily get the data I want in a simple query like this:
SELECT Date, LOCATION,
             pTypeCode,
             Count(pTypeCode),
             Sum(Amt) AS Prem
FROM [dbo].[CommisionEntry]
WHERE Date >=
    (SELECT DATEADD(DAY, 1, EOMONTH(GetDate(), -1)))
  AND Date <=
    (SELECT EOMONTH(GetDate()))
GROUP BY date, LOCATION,
               pTypeCode
But I need the count(pTypeCode) = P and C And EB in the row also like so:
Date  Count(pTypeCode) C    Count(pTypeCode) P  Count(pTypeCode) EB    SUM(Amt)
1/1/2015  2  1  1  550.94
Any help would be appreciated.
Thanks
 
     
    