Link to home
Start Free TrialLog in
Avatar of fax

asked on

How to return a simple histogram from sql server?


I have a database containing a table with information about the scuba diving I did. I am trying to get out of this data a histogram of the number of dives I did each year. I tried to do that with the following SQL code:

SELECT Year(Dives.Datum) as Jaar, Count(theyear) as Aantal FROM Dives;
SELECT Year(Dives.Datum) as Jaar, Count(Year(Dives.Datum)) as Aantal FROM Dives;

where Jaar is the dutch word for Year, Datum for Date and Aantal for Number/Count

But when I do this in Access, I get an error about trying to execute this query that does not include the specified expression 'Year(Dives.Datum)' as part of an aggregate function. I'm afraid I don't really get the meaning of this error.

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fax


Wow! That was fast! It works!

I would have never guessed that from the 'aggregate function' error...still don't really get what access was trying to tell me.

Thanks a bunch!