|
-
crosstab query (pivot)
Hi,
I've this table CROSS:
ID AREA TYPE CATEGORY
01 20 OFFICE SPACE
01 30 OFFICE SPACE
01 50 ARCHIVES SPACE
02 10 MEETING SPACE
02 10 MEETING SPACE
02 100 ARCHIVES SPACE
03 20 SERVICE PLAN
03 20 MEETING SPACE
03 80 ARCHIVES SPACE
I created this query for get a crosstab (rows become columns):
select
ID,
sum(decode(type,'OFFICE',area,0)) office,
sum(decode(type,'ARCHIVES',area,0)) archives,
sum(decode(category,'SPACE',area,0)) space,
sum(decode(category,'PLAN',area,0)) plan
from CROSS
group by id
It's correct but now my problem is this:
If Type or Category changes name (for example OFFICE become HOME), my crosstab is incorrect.
Is it possibile create a dynamic query that change automatically type or category columns??
Thanks in advance!
Raf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|