DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: problem with a query

  1. #1
    Join Date
    Jul 2002
    Posts
    228

    problem with a query

    Hi,
    I've this table:

    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'd like to create a query to get this output:

    ID OFFICE SERVICE SPACE PLAN ARCHIVES MEETING
    01 50 0 100 0 0 0
    02 0 0 110 10 100 20
    03 0 20 100 20 80 20


    50 is sum(area) of ID=01 FOR TYPE=OFFICE.............

    This is a crosstab query, I don't know if Oracle Can create a crosstab query, I hope so.

    Could you help me??
    Thanks
    Raf

  2. #2
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Code:
    select id, type, sum(area)
    from table
    grou by id, type;
    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  3. #3
    Join Date
    Jul 2002
    Posts
    228
    sorry, but this query has id, type, area columns.

    I want this columns:
    id, OFFICE SERVICE SPACE PLAN ARCHIVES MEETING


    Thanks

  4. #4
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    search the forum for "crosstab" and "pivot"
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width