Link to home
Create AccountLog 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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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