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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a query to get monthly totals

Status
Not open for further replies.

rbeatty

MIS
Joined
Oct 28, 2002
Messages
8
Location
US
How do I go about a query that recongnizes when a month passes and then takes the total of a numerical field in my database.

Thanks
Roger
 
Code:
select sum(amount)
  from yourtable
 where day(date()) = 01
   and month(date()) - month(datecol) = 1

produces output only on the first of every month

selects all rows where the datecol is previous month

caution: does not work in january!! you should be able to figure that out using the year() function :-)

rudy
 
Thanks alot Rudy, that helped out.

Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top