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
 query to show only users who logged on in past 6 m

Author  Topic 

unikoman
Starting Member

32 Posts

Posted - 2006-02-20 : 05:14:24
Hi All

I have built this query :

Select position, SubsidiaryName
from position
Where SubsidiaryName in ('country1','country2')
and position not like('testuser_%')
and position not like ('Inactive_%')
and position not like('olduser_%');

However when I run it, the result more accounts in country 1 than expected. I think it could be inactive users who have not logged into this system for 6 months or more. How can I build a query that incorporates my original query + shows only users who logged into the past 6 months ?


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-20 : 05:24:43
Select position, SubsidiaryName
from position
Where SubsidiaryName in ('country1','country2')
and LoggedDate>=DateAdd(day,dateDiff(day,0,DateAdd(month,-6,getdate())),0)
and position not like('testuser_%')
and position not like ('Inactive_%')
and position not like('olduser_%');


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-02-20 : 05:30:22
thanks Madhivanan:) you are a legend:)
Go to Top of Page
   

- Advertisement -