Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 A way to filter by month/day w/o using case when

Author  Topic 

rc1138
Starting Member

35 Posts

Posted - 2010-05-24 : 21:51:13
Guys,

Trying to formulate an SQL query to count the number of activities within a month or day (Weekday) without using case when or pivot but so far has been unsuccessfull

SELECT COUNT(MONTH(irActivity.ActivityDate)) AS 'JAN', COUNT(MONTH(irIncident.IncDate)) AS 'FEB' FROM irActivity INNER JOIN
pdEmployee ON irActivity.Comp = pdEmployee.Comp
Order By 'JAN'

This is where I'm receiving the error - I'm trying to put a filter in this section of the query

"COUNT(MONTH(irActivity.ActivityDate) = '1') "

"Syntax error close to ="

Any help would be greatly appreciated!

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-05-24 : 23:44:43
Why is it important not to use a CASE statement?


CODO ERGO SUM
Go to Top of Page

zstarsales04
Starting Member

20 Posts

Posted - 2010-05-25 : 02:17:39
spam removed
Go to Top of Page

rc1138
Starting Member

35 Posts

Posted - 2010-05-25 : 05:43:27
Hi Michael,

Can't really use a Case statement due to a driver
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-05-25 : 07:05:56
Which driver are you using? Is this for Microsoft SQL Server or another product?
Go to Top of Page

rc1138
Starting Member

35 Posts

Posted - 2010-05-25 : 21:43:52
its for Relativity ODBC driver
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-05-25 : 22:01:58
You should consult the documentation for the DBMS you are using.

This is a Microsoft SQL Server forum, and the TSQL syntax that SQL Server uses will probably not be supported by "Relativity".



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -