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

having troubles with sorting data based on date parts

Status
Not open for further replies.

03Explorer

Technical User
Sep 13, 2005
304
US
I want to group data based on the Month and Year for counts.

I have a field that is Date/Time named [callstartdate] and I keep getting an error with the following code

Code:
select 
  Year(Callstartdate) Year, 
  month(callstartdate) Month, 
  appname, 
  count(sessionid) Total_Calls
from 
  vxmlsession
where 
  month(callstartdate) = 6 
  and year(callstartdate) = 2008
group by 
  year(callstartdate), 
  Month(callstartdate), 
  appname
order by 
  appname ASC

All I get is 'A Syntax Error has occured' Where is my hangup?
 
I found another thread that helped... because the first two items were 'odd' (lack of a better reason) I grouped by Item 1 and then 2... the code came out like this and works!

Code:
select 
  Year(Callstartdate) Year, 
  month(callstartdate) Month, 
  appname, 
  count(sessionid) Total_Calls
from 
  vxmlsession
where 
  month(callstartdate) > 5 
  and year(callstartdate) = 2008
group by 
  1, 
  2, 
  appname
order by 
  appname ASC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top