Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2008-07-31 : 17:54:20
|
| Hello, I have these two tables Header_Data and Zone_Data. The first one stores header information received from hourly data files and the second one stores details information for each hour in a row(Data_Hour column stores values like 1,2....24 for 24 hours of the day and other columns store data values for the hour).So, Zone_Data is related to the Header_Data by a foreign key "Header_Num". I want to write a query that will create a row for each day of a month (It can take only one month at a time) and fetch the data values for each hour of the day.Because I am going to display them in a Grid that will have 31 Rows for 31 days in July, 24 Columns for each hour of the day.Any idea how I can do this?Thanks. |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-31 : 19:03:03
|
| Either use CASE statements or have a look at the PIVOT statement http://weblogs.asp.net/salimfayad/archive/2008/01/30/rows-to-columns.aspx |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2008-08-01 : 00:11:04
|
| Thanks Dexter. |
 |
|
|
|
|
|