Month and YTD total [message #133087] |
Wed, 17 August 2005 12:07 |
reach_honey
Messages: 10 Registered: June 2005 Location: Boston
|
Junior Member |
|
|
I'm trying to display monthly and ytd total on my sql.
For ex. table A has following data
Description ID Receipt_date
1 1 01-jul-05
1 2 05-JUL-05
1 3 01-FEB-05
2 4 01-JUL-05
2 5 31-JUL-05
2 6 01_JAN-05
My output for month of July and YTD should be as
Description Month total Year total
1 2 3
2 2 3
I have 2 different sql but how do i combine into one to get this required value.
SQL
select x.description,count(y.id)monthly
from x,y,z
where x.id=y.id and
y.id=z.id and
z_signed_dt ='Y' and
x.receipt_date between 01-JUL-05 and 31-JUL-05
-----------
Yearly
select x.description,count(y.id)yearly
from x,y,z
where x.id=y.id and
y.id=z.id and
z_signed_dt ='Y' and
x.receipt_date between 01-JAN-05 and 31-JUL-05
How do i combine and bring them into one value?
Any help would be appreciate.
Thanks,
Reach_honey
|
|
|
|