Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get sum of amount for previous 3 months (dynamically)

Status
Not open for further replies.

compbiz

Programmer
Apr 3, 2003
2
0
0
IN
I have 3 tables
district
dist_code dist_name
11 LA
12 WA

demands
dist_name year demandfortheyear
LA 1999 3434.44

dues
dist_name month year currentdue
LA 1 1999 890
LA 2 1999 656
LA 3 1999 455
LA 4 1999 4554

if current year is 1999 and month is 4 I want to retrieve it from system date and get sum of currentdue for previous 3 months(1 to 3)
 
hi

try ist this way:

select sum(currentdue)
from dues
where year = year(current date)
and month < month(current date)


martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top