Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with a query
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01098460
Message ID:
01098487
Views:
13
>>>I have a table with a datetime field. I would like to count the number of records that exist per year to get a result set something like this:
>>>
>>>
>>>count    year
>>>-----    ----
>>>42       1994
>>>67       1995
>>>    .
>>>    .
>>>    .
>>>234      2005
>>>42       2006
>>>
>>>
>>>Any assistance would be appreciated.
>>>
>>>Thanks,
>>>Einar
>>
>>
>>SELECT YEAR(datetimefield) ,count(*) from table group by YEAR(datetimefield)
>>
>

As far as I know, year() is a VFP function. Try DATEPART instead:

select datepart(yy, datetimefield)....

>Thank you very much for the prompt reply. The only problem I ran into is that I am querying a Paradox table using the Borland SQL Explorer. I was hoping that Paradox used "standard" SQL syntax but it doesn't like the YEAR(fieldname).
>Ohh well I might have to do it the hard way.
>
>Einar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform