1
我想結合我的2個sql結果和1個更多的日期過濾器。 如何合併我的這2個sql查詢。組合2 SQL查詢結果
第一個SQL
SELECT e.Name,COUNT(l.userName) as UsersVisit
FROM Table1 l
INNER JOIN Table2 e on e.UserName =l.UserName
WHERE
(l.DateAccessed>'3-31-2015' and l.DateAccessed <'4-30-2015')
Group by e.Name
O/P我得到
Name UsersVisit
abc 10
xyz 20
def 30
第二個SQL
SELECT COUNT(1) as TotalVisits
FROM Table1 l
INNER JOIN Table2 e on e.UserName =l.UserName
WHERE
(l.DateAccessed>'3-31-2015' and l.DateAccessed <'4-30-2015')
ORDER BY TotalVisits DESC
O/P我得到
TotalVisits
60
現在,O/PI想是
UniqueUsers TotalVisits Month
3 60 March
4 50 April
3是用戶(ABC,XYZ,DEF)的唯一編號,同時TotalVisits是所有UsersVisit
我怎樣才能得到這些計數結果?
'group by usersvisit,month' ... –