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:
TamilCode: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




Reply With Quote