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

Thread: pl/sql challenge

Threaded View

  1. #6
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Tom Kyte wrote a package for dynamically pivoting the result set in his book "Expert one-on-one" .

    It's worth to buy the book.

    Here is the another simple SQL:
    Code:
     1  select insert_user, model,
      2         sum( case when trunc(insert_date) = to_date('17-APR-2006', 'DD-MON-YYYY')
      3                   then  1
      4              end ) "04/17/2006" ,
      5         sum( case when trunc(insert_date) = to_date('18-APR-2006', 'DD-MON-YYYY')
      6                 then  1
      7             end ) "04/18/2006",
      8         sum( case when trunc(insert_date) = to_date('17-APR-2006', 'DD-MON-YYYY')
      9                   then  1
     10              end )+
     11         sum( case when trunc(insert_date) = to_date('18-APR-2006', 'DD-MON-YYYY')
     12                 then  1
     13             end ) total
     14  from test
     15* group by insert_user, model
     16  /
    
    INSERT_U MODEL                04/17/2006 04/18/2006      TOTAL
    -------- -------------------- ---------- ---------- ----------
    John     ModelA                        1          1          2
    John     ModelB                        1          1          2
    Sara     ModelA                        1          1          2
    Sara     ModelB                        1          1          2
    Tamil
    Tamil
    Last edited by tamilselvan; 04-18-2006 at 01:49 PM.

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