UserName| Time Frame| No of Applications
Daniel | Week to date| 3
Daniel
| Month to date| 10
Daniel| Year to date|400
Please help me get the above format, below is my statement and output.
select j.UserName, i.App_Date as "Time Frame", count(*) as "Num. of Applications"
from tblApplication as i, tblUsers as j
where i.User_ID = j.User_ID
group by j.UserName, i.App_Date
union
select distinct a.UserName, b.App_Date, count(b.User_ID)
from tblUsers as a left join tblApplication as b on a.User_ID = b.User_ID
where b.User_ID is null
group by a.UserName, b.App_Date
UserName | Time Frame | Num. of Applications |
---|---|---|
Daniel | 3 | |
Daniel | 12/31/2012 12:00:00 AM | 1 |
Daniel | 1/1/2013 12:00:00 AM | 1 |
Daniel | 2/17/2013 10:37:15 AM | 1 |
Daniel | 2/18/2013 10:37:15 AM | 1 |
Daniel | 2/19/2013 10:37:15 AM | 1 |
Daniel | 2/20/2013 10:37:15 AM | 1 |
Daniel | 2/21/2013 10:37:15 AM | 1 |
Daniel | 2/22/2013 10:37:15 AM | 1 |