jclem1
asked on
SQL SERVER 2005 DateName trouble
Experts, I cannot seem to get the below query to give the output I am looking for. I am using datename to pull out the month and year parts from the closed data of a trouble ticket, however when I use them as below I cannot use AS [MonthName] or AS [YearName] for column headers (or any other wording). I receive an error around "AS".
Any help would be appreciated.
Thanks
Any help would be appreciated.
Thanks
Declare @txtTo varchar (10)
Declare @txtTo_2 varchar (10)
SET @txtTo = '1/1/2008'
SET @txtTo_2 = '1/1/2009'
Select Datename(mm,closed) ,Datename(yy,closed), src_sys,report#, repo_type, vz_svc_type_2,SUM(RESP_DUR/60)MTTR, chronic_cnt, cktfmt, installation_failure, total_ho,trbl_code, an_code, loc_z
From dbo.[maint_allrepotype>_2008]
Where closed >= convert(datetime, @txtTo, 101)
group by Datename(mm,closed),Datename(yy,closed), src_sys,report#, repo_type, vz_svc_type_2,RESP_DUR, chronic_cnt, cktfmt, installation_failure, total_ho,trbl_code,an_code, loc_z
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select case when datename(mm, getdate()) = 'May' then datename(mm, getdate()) end 'May'
you'll need one for each month