pivot in t-sql

  • Thread starter Mitchell_Collen via AccessMonster.com
  • Start date
M

Mitchell_Collen via AccessMonster.com

Please help me to do this. I am trying to make a pivot query using t-sql.

SELECT Area, Total,1,2,3
FROM (SELECT HOUR,AREA,
CASE
WHEN HOUR = 1 THEN '1:00'
WHEN HOUR = 2 THEN '2:00'
WHEN HOUR = 3 THEN '3:00'
END As Hour_Interval
FROM Pharmacy.ORDERS_AGG_AREAS_HH As C
GROUP BY HOUR,AREA
PIVOT (COUNT(HOUR) FOR Hour_Interval IN (1,2,3))) As P <---message
says error generated near 'Pivot'

Should output this:
Area Total, 1:00, 2:00, 3:00
5 nor 15 2 0 56
6 nor 3 1 3 43
 
D

Douglas J. Steele

I'd recommend asking this in a newsgroup related to SQL Server.

There are too many differences between Access SQL and T-SQL, and the SQL
Server gurus will have a better idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top