471,073 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Sum fields

Hi All

I need some help.
I have a table with 2 fields (Nights and year) that looks like this:
Nights, Year
1, 2004
2, 2004
44, 2005
45, 2005

Now I want to make an sql query that returns a sum of each year like this:

field 2004,2005
Data 3, 89

How can I make this work?


Jul 23 '05 #1
1 2130
Try the "Group by" clause and use the "SUM" operator.


Select Sum(Nights) as TotalNights, Year
From Table1

Group By Year

Hope this helps.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tim Cowan | last post: by
reply views Thread by bill mahoney | last post: by
reply views Thread by Proteus | last post: by
4 posts views Thread by Vigneshwar Pilli via DotNetMonster.com | last post: by
9 posts views Thread by sean.scanlon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.