Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mystery of PIVOT, or is it???

Status
Not open for further replies.

eo

MIS
Apr 3, 2003
809
Hi,

I think this is quite unique, but there is hopefully a way to achieve this.

My data has 2 identifyers and 3 values:

Code:
state   city       value1   value2   value3
SA      Adealide   100      50       60
SA      Port Adl   20       50       20
WA      Perth      15       20       10
WA      Fremantle  25       80       60

I actually need to use the value labels as slicers so need the data as

Code:
State  City     KPI     Value
SA     Adelaide Value1  100
SA     Adelaide Value2   50
SA     Adelaide Value3   60
SA     Port Adl Valie1   20
....

Is this at all possible?

Many thanks,
EO

EO
Hertfordshire, England
 
On the data given, I'd use UNION ALL
Code:
SELECT [State], [City], 'Value1', [value1] from TABLE
UNION ALL
SELECT [State], [City], 'Value2', [value2] from TABLE
UNION ALL
SELECT [State], [City], 'Value3', [value3] from TABLE
ORDER by 1,2,3


soi là, soi carré
 
UNPIVOT not available in SS 2000, but I guess that that version is now quite rare.

soi là, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top