Experts, I am in the process of converting from an Oracle database to SQL server 2005. I previously used TOAD for Oracle as a querying interface which is where the example code below comes from.
My problem is that I can't get the below query to run in my SQL server. The problem is with the truncate function on the date, in oracle I could use trunc(closed,'MON') or trunc (closed,'YYYY') or to_char(closed,'HH') depending on how I wanted to manipulate the closed date of the trouble ticket.
Please tell me there is something equvalent in SQL that gives me the same options and is just as user friendly, if I have to build it as a script or stored procedure or something that is fine. I just need something because I change the date criteria every day in various ad hoc queries depending on what people ask for.
select trunc(CLOSED, 'MON')Month,SRC_SYS,vz_svc_type, sum(RESP_DUR/60) Total_Hours , count (1) Reports
where trunc(CLOSED, 'Mon') = '01-APR-2009'
and VZ_SVC_TYPE != 'UNK'
group by trunc(CLOSED, 'MON'), SRC_SYS,vz_svc_type