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

What query to use???

Status
Not open for further replies.

millrat

Technical User
Dec 23, 2003
98
US
Hi,
What type of query would I use to get the following result and how?

Eg table.

[Date] [Total]
01/02/06 100
01/02/06 75
02/02/06 100
02/02/06 50

Result needed

[Date] [SumOfTotal]
01/02/06 175
02/02/06 150

I've tried all I know but still cannot get it.
Help would be appreciated
Thanks
millrat
 
Code:
Select [Date],Sum([Date])
FROM Table
GROUP BY [Date]
the key is the group by statement
 
oops, do this

Select [Date],Sum([Total]) as [SumOfTotal]
FROM Table
GROUP BY [Date]
 
Hi IT4EVR,
Thanks for the reply.
I did as you suggested but still get many records for the same date. Basically I need to sum the [total] for each record where the [date] is the same. eg on a given day there may be 15 records for [total] (same date)
Cheers,
millrat
 
is your date field in short date format? or long date format?

if it is in short date format, then my second post should work for you
 
We could be onto something here. Even though in short date format, the query is giving a date and time..the times are different, this may explain it. I try to sort out the formatting and let you know
Cheers
 
Sounds like you have somehow configured a default value of now() or a general date format.

To coerce a short date format do this:

Code:
SELECT Format(Table1.Date,"Short Date"), Sum(Table1.total) AS SumOftotal
FROM Table1
GROUP BY  Format(Table1.Date,"Short Date");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top