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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Strange results

Author  Topic 

Cyclonik
Posting Yak Master

114 Posts

Posted - 2001-03-16 : 21:45:06
I have this query...

Select a.fname,a.lname,
COUNT(b.monitor_id) as TotalMonitors
from tblUsersT a LEFT JOIN tblEmail_MonitorsTech b on a.lanid=b.monitored_by_id Where (positionid = 3 or positionid = 2) and
(monitor_date BETWEEN '03/01/01' and '03/31/01' OR b.monitor_date Is Null)
Group by a.fname,a.lname, a.lanid order by a.lname, a.fname

i want a list of all the records in the tblUsersT to be returned plus the totals from the aggregate for the date range specified. it works unless a user has no matching records in the specified range in the tblEmail_MonitorsTech table but has records that match outside of that daterange. for instance "Jon" only has a record for '02/05/01' he won't be returned. if has no previous monitors nor any in the date range he will be returned with a 0 total as he should. any clue how to resolve this? i think this
(monitor_date BETWEEN '03/01/01' and '03/31/01' OR b.monitor_date Is Null) is the culprate. Hope thats clear

Thanks
Christian

-=:SpasmatiK:=-
   

- Advertisement -