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.
| Author |
Topic |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2009-09-01 : 15:28:05
|
| I am using the following select query via UDF function:It is working fine on the server, but on my local machine it is not working.SELECT 1 FROM dbo.Table_Activity A WHERE A.Step = (SELECT MIN(Step) FROM dbo.Table_Activity WHERE DoneDate IS NULL) AND A.ActivityId = 49 AND A.DoneDate IS NULLi have a row where donedate is null for that particular activity ID.Is there another way to query?Thank you very much for tthe helpful info. |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2009-09-01 : 15:59:03
|
| Is there a key in there somewhere? What exactly are you trying to achieve?An infinite universe is the ultimate cartesian product. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-09-01 : 16:00:15
|
The Clause: (SELECT MIN(Step) FROM dbo.Table_Activity WHERE DoneDate IS NULL) Will get you the MIN Step from ANY row where DoneDate is null. Which won't nessecarily match to a record where ActivityID is 49. Do you need this to be like this? (SELECT MIN(Step) FROM dbo.Table_Activity WHERE DoneDate IS NULL AND ActivityID = 49)Maybe this? SELECT CASE WHEN MIN(Step) IS NULL THEN NULL ELSE 1 END AS RetValFROM dbo.Table_Activity WHERE DoneDate IS NULL AND ActivityId = 49 |
 |
|
|
|
|
|