Number of records by Year - SQL Query Help

  • Hi,

    I have a table called 'suggestions' where I have 'suggestionDate' and some other fields. 'suggestionDate' has value like '9/12/2007'. The table will have information on number of suggestions per year.  I need an output like 'Number of Suggestions Per Year' as follows.

    2007 12

    2006  9

    2005 11

    2004 10

    How can I do that ? I have only a clue that I need to use DISTINCT, YEAR function, GROUP BY and ORDER BY. But, I could not figure out the exact query to get the above resultset. Please help.

    Thanks

    vmrao

  • select year(SuggestionDate) as YearOfSuggestion, count(*) as Total

    from suggestions

    group by year(SuggestionDate)

    order by year(SuggestionDate)


    * Noel

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply