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
 What that query does

Author  Topic 

mukhan85
Starting Member

46 Posts

Posted - 2009-08-17 : 11:33:33
Hi, that is the old code written by somebody,
Have no idea what it does, seems even incorrect.



SELECT count(*)
FROM Task
WHERE Status = 6000 and (Status NOT IN (6000,7000)
OR CONVERT(char(4),DATEADD(second, Create_Date, '1969-12-31 8:00:00 PM'),112) >= '2006'
OR CONVERT(char(4),DATEADD(second, Actual_End_Date, '1969-12-31 8:00:00 PM'),112) >= '2006')


Thanks.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-17 : 11:56:43
Well, the "SELECT count(*)" part will return the count of all the rows contained in the FROM clause that satisfy the criterial in the WHERE clause.

The WHERE clause is broken. The DATEADD function is not structured properly.
There is also a combination of AND/OR conditions. You typically would isolate them from each other using parenthises. possibly like this:

where (A=A OR B=A) AND C=C

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -