I want to combine my 2 sql results and 1 more filter which is Date.
How Can I combine my these 2 sql queries.
First 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 I get
Name UsersVisit
abc 10
xyz 20
def 30
Second 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 I get
TotalVisits
60
Now, the O/P I want is
UniqueUsers TotalVisits Month
3 60 March
4 50 April
3 is the unique number of users(abc,xyz,def), while TotalVisits is the count of all the UsersVisit
How can I get these result ?
Copyright Notice:Content Author:「hello temp11」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/31213078/combine-2-sql-query-results