Help with creating a view...
Posted in 1999
I need to take a series of columns, and essentially rotate them so that
they are a series of rows.
I have an SQL mechanism that does this:
select pageid,1 as story,story1 as id from livearticles where timeup isnull and timedown is null
union
select pageid,2,story2 from livearticles where timeup is null andtimedown is null
union
select pageid,3,story3 from livearticles where timeup is null andtimedown is null
union
select pageid,4,story4 from livearticles where timeup is null andtimedown is null
union
select pageid,5,story5 from livearticles where timeup is null andtimedown is null
union
select pageid,6,story6 from livearticles where timeup is null andtimedown is null
union
select pageid,7,story7 from livearticles where timeup is null andtimedown is null
union
select pageid,8,story8 from livearticles where timeup is null andtimedown is null
The union operator prevents me from being able to put this in a view.
Can anyone suggest an alternative query that might accomplish the same
things without the union operators?
the table's schema is:
create table livearticles
(
pageid integer,
timeup datetime year to second,
timedown datetime year to second,
story1 integer,
story2 integer,
story3 integer,
story4 integer,
story5 integer,
story6 integer,
story7 integer,story8 integer
);
--
David Buttrick http://www.sportingnews.com
WEB Database Specialist
The Sporting News buttrick@sportingnews.com
- When you wish upon a star... -
S E E A D I F F E R E N T G A M E