Print Page | Close Window

Sales Report By Month

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10724
Printed Date: 29 March 2026 at 8:34pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Sales Report By Month
Posted By: ngaisteve1
Subject: Sales Report By Month
Date Posted: 04 June 2004 at 2:48am
If I need to generate a report, let's say by sales by month,

Month | Total Sales
Jan | 32,020
Feb | 29,400
Mar | 30,000
Apr | 31,500
May | 40,801
Jun | -
Jul | -
Aug | -
Sep | -
Oct | -
Nov | -
Dec | -

How my sql query roughly look like? my datatype for date is date.
select * from sales where date = ???

Thanks.



Replies:
Posted By: Phat
Date Posted: 04 June 2004 at 3:40am
There is a few ways to do this depending on your data structure.

1. If you haev many sales each month and need to add them up then you could use.

Sql = SELECT Sum(tblSales.SalesField) AS SumOfSalesField
FROM tblSales
WHERE (((tblSales.DateField) Between #6/1/2004# And #6/30/2004#));

or
2. If you have a total sales field then use

Sql = SELECT tblSales.SalesField
FROM tblSales
WHERE (((tblSales.DateField) Between #6/1/2004# And #6/30/2004#));

Do not use date as the name of the field either as this will cause problems with the sql.


Posted By: ngaisteve1
Date Posted: 04 June 2004 at 5:19am

thanks, ur gave idea of using between.



Posted By: ljamal
Date Posted: 04 June 2004 at 10:47am
Is this a MSSQL DB?
If so, I'd suggest one one query to return the data

select datepart(m,datefield), datepart(y,datefield), sum(salesfields) from tblSalesData group by datepart(y,datefield), datepart(m,datefield)

This will return the month, year and sales total for each month in one recordset.


-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: ngaisteve1
Date Posted: 06 June 2004 at 11:58pm

I'm using MySql.

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net