Link to home
Start Free TrialLog in
Avatar of James Murrell
James MurrellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

each month

bit brain dead today, i have this code, how can i make it automatically do previous month at the mo i have to enter manually....


select count(*) as times,member_id,licensed,used 
from user_count 
where used > licensed+1 and dt_stamp between '2007-02-01' and '2007-02-28'
group by member_id,licensed,used
order by member_id, used

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Lee Osborne
Lee Osborne
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
select count(*) as times,member_id,licensed,used
from user_count
where used > licensed+1 and dt_stamp between dateadd(m, -1, getdate()) and gettdate()
group by member_id,licensed,used
order by member_id, used