group by date only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

Can you help me with this query below  Mgr's could circumvent the process by
login 20 times in 1 day and change the login attempts. This is a rolling 30
window my upper mgmt would like to track. 

 

select user, count(user) as num from LoginTrack 

          where user and t='M' and DATE_SUB(CURDATE(),INTERVAL 30 DAY) <=
date 

               group by user 

               order by num desc";

 

 

I have a dilemma trying to combine the data below. The problem is that when
users login several times a day I only want to count it a 1 login not 5 or
more. I tried group by date and because the time is in the date that did not
work. Any help would be appreciated !!!

 

Ideally the data below should return 

 

mgrtft          1        

mgrschultz   2        

mgrreid        1        

 

// Table data below:

 

varchar        datetime                char   

user             date                      t


mgrtft

2005-06-21 10:17:00

M


mgrtft

2005-06-21 10:16:00

M


mgrschultz

2005-06-21 09:12:00

M


mgrschultz

2005-06-21 08:56:00

M


mgrschultz

2005-06-21 08:26:00

M


mgrreid

2005-06-21 08:26:00

M


mgrschultz

2005-05-21 08:16:00

M


mgrschultz

2005-06-21 08:07:00

M


mgrtft

2005-06-21 07:46:00

M

 

Larry Sandwick

Sarreid, Ltd.

www.sarreid.com

Network/System Administrator

P:(252) 291-1414 223

F:(252) 237-1592

 


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux