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 |
sqldba20
Posting Yak Master
183 Posts |
Posted - 2010-09-28 : 10:45:19
|
Folks:I have a table with date columns. Everyday a new column will be added (date) to the table. The Name column is character and the rest all are int. Table Structure:Name, [09/23/2010],[09/24/2010],[09/25/2010],[09/26/2010],[09/27/2010],[09/28/2010],TotalValueQuestion: I want to pull data only for last 5 days. Can this be achieve without pivot/unpivot if not then how will be my pivot/unpivot SQL Statement?Thanks ! |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2010-09-28 : 16:10:52
|
That is not a good design for a table for a lot of reasons...Such as: At some point sql server will complain about too many columns. Every day you have to write (or generate) new sql statements to query the data. Your table should be ([name], [date], [value])Just keep adding new rows rather than new columns.Be One with the OptimizerTG |
 |
|
|
|
|