Subject | Pivot table report |
---|---|
Author | Çağatay Tengiz |
Post date | 2001-11-13T16:58:11Z |
Hi,
Sıppose I've a sales table which has the fields of sale_amount, sale_month
and sale_year.
So data has the following format
Year Month Amount
---- ----- ------
2001 1 100
2001 2 100
2002 1 300
and my problem is, showing data like this format
1 2
2001 100 100
2002 300
I'm using
select year,
(select amount from mytable mt where mt.year = mt00.year) as m1,
(select amount from mytable mt where mt.year = mt00.year) as m2,
.
.
.
from mytable
but this query takes too much time...
is there any better SQL solution?
Cagatay Tengiz
cagatay.tengiz@...
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Tengiz Engineering & Consultancy
www.tengiz.net
Phone : +90 232 388 07 01
Fax : +90 232 373 42 63
Kazim Karabekir Cad. No:47/B 35040
Bornova - Izmir / TURKEY
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
_________________________________________________________
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com
Sıppose I've a sales table which has the fields of sale_amount, sale_month
and sale_year.
So data has the following format
Year Month Amount
---- ----- ------
2001 1 100
2001 2 100
2002 1 300
and my problem is, showing data like this format
1 2
2001 100 100
2002 300
I'm using
select year,
(select amount from mytable mt where mt.year = mt00.year) as m1,
(select amount from mytable mt where mt.year = mt00.year) as m2,
.
.
.
from mytable
but this query takes too much time...
is there any better SQL solution?
Cagatay Tengiz
cagatay.tengiz@...
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Tengiz Engineering & Consultancy
www.tengiz.net
Phone : +90 232 388 07 01
Fax : +90 232 373 42 63
Kazim Karabekir Cad. No:47/B 35040
Bornova - Izmir / TURKEY
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
_________________________________________________________
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com