MS SQL Server 2000
I have a table that I need to unpivot the columns, and UNPIVOT does not work in 2000.
In 2005 I would do the following;
select username, fieldname as dept, dept_value from TABLENAME
UNpivot
(dept_Value for fieldname in (10,20,30)) as uPVT
Where upvt.dept_value = 1
How can this be accomplished in 2000?
The table structure is;
username |dept 10 | dept 20 | dept 30
jsmith 1 0 1
Desired results to be;
Username | Dept | Dept_Value
jsmith 10 1
jsmith 30 1
A records for jsmith | dept 20 would be excluded because the dept_value = 0.
Thanks,
awaria
I have a table that I need to unpivot the columns, and UNPIVOT does not work in 2000.
In 2005 I would do the following;
select username, fieldname as dept, dept_value from TABLENAME
UNpivot
(dept_Value for fieldname in (10,20,30)) as uPVT
Where upvt.dept_value = 1
How can this be accomplished in 2000?
The table structure is;
username |dept 10 | dept 20 | dept 30
jsmith 1 0 1
Desired results to be;
Username | Dept | Dept_Value
jsmith 10 1
jsmith 30 1
A records for jsmith | dept 20 would be excluded because the dept_value = 0.
Thanks,
awaria