I'm trying to manipulate some data into a table.
the results of the query are
date 9:00 10:00 11:00 12:00
1/09/03 0 2 7 4
2/09/03 1 5 9 15
and I neesd to insert into
date timeslot Value
1/09/03 9:00 0
1/09/03 10:00 2
1/09/03 11:00 7
1/09/03 12:00 4
2/09/03 9:00 1
etc
my code to get the date looks like
SELECT date,
SUM(CASE
WHEN [start] <= '09:00' And [end]> '09:29'THEN 1 ELSE 0 END) AS [09:00],
SUM(CASE
WHEN [start] <= '10:00' And [end]> '10:29'THEN 1 ELSE 0 END) AS [10:00],
SUM(CASE
WHEN [start] <= '11:00' And [end]>'11:29' THEN 1 ELSE 0 END) AS [11:00],
FROM aTAble
Any ideas on how to pivot the data within an insert??????????
the results of the query are
date 9:00 10:00 11:00 12:00
1/09/03 0 2 7 4
2/09/03 1 5 9 15
and I neesd to insert into
date timeslot Value
1/09/03 9:00 0
1/09/03 10:00 2
1/09/03 11:00 7
1/09/03 12:00 4
2/09/03 9:00 1
etc
my code to get the date looks like
SELECT date,
SUM(CASE
WHEN [start] <= '09:00' And [end]> '09:29'THEN 1 ELSE 0 END) AS [09:00],
SUM(CASE
WHEN [start] <= '10:00' And [end]> '10:29'THEN 1 ELSE 0 END) AS [10:00],
SUM(CASE
WHEN [start] <= '11:00' And [end]>'11:29' THEN 1 ELSE 0 END) AS [11:00],
FROM aTAble
Any ideas on how to pivot the data within an insert??????????