joining two queries
-
select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Calls] from status join empmaster on empmaster.empid = status.empcode where empmaster.Permission <> '1' and logintime between '06/02/2006' and '06/03/2006' group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by empcode asc select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Contacts] from status join empmaster on empmaster.empid = status.employeecode where empmaster.Permission <> '1' and logintime between '06/02/2008' and '06/03/2008' and statuscode not in (11)group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by emp asc i have these two queries.the problem is how to join these queries? can any one help me.if i write two queries as one,data of two columns ( [no of calls] and [no of contacts]) resulting same count.
-
select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Calls] from status join empmaster on empmaster.empid = status.empcode where empmaster.Permission <> '1' and logintime between '06/02/2006' and '06/03/2006' group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by empcode asc select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Contacts] from status join empmaster on empmaster.empid = status.employeecode where empmaster.Permission <> '1' and logintime between '06/02/2008' and '06/03/2008' and statuscode not in (11)group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by emp asc i have these two queries.the problem is how to join these queries? can any one help me.if i write two queries as one,data of two columns ( [no of calls] and [no of contacts]) resulting same count.
use
UNION
select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Calls] from status join empmaster on empmaster.empid = status.empcode where empmaster.Permission <> '1' and logintime between '06/02/2006' and '06/03/2006' group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by empcode asc **UNOIN** select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Contacts] from status join empmaster on empmaster.empid = status.employeecode where empmaster.Permission <> '1' and logintime between '06/02/2008' and '06/03/2008' and statuscode not in (11)group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by emp asc
I Love T-SQL "Don't torture yourself,let the life to do it for you."
-
use
UNION
select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Calls] from status join empmaster on empmaster.empid = status.empcode where empmaster.Permission <> '1' and logintime between '06/02/2006' and '06/03/2006' group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by empcode asc **UNOIN** select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Contacts] from status join empmaster on empmaster.empid = status.employeecode where empmaster.Permission <> '1' and logintime between '06/02/2008' and '06/03/2008' and statuscode not in (11)group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by emp asc
I Love T-SQL "Don't torture yourself,let the life to do it for you."
-
Yes you are right, I forgot to write UNION ALL in both two places on my first response.Thanks for correcting me dude.
I Love T-SQL "Don't torture yourself,let the life to do it for you."
-
select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Calls] from status join empmaster on empmaster.empid = status.empcode where empmaster.Permission <> '1' and logintime between '06/02/2006' and '06/03/2006' group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by empcode asc select convert(varchar(10),status.Logintime ,101) as Date,empcode,empname,count(*) as [No of Contacts] from status join empmaster on empmaster.empid = status.employeecode where empmaster.Permission <> '1' and logintime between '06/02/2008' and '06/03/2008' and statuscode not in (11)group by empcode,empname, convert(varchar(10),status.Logintime ,101) order by emp asc i have these two queries.the problem is how to join these queries? can any one help me.if i write two queries as one,data of two columns ( [no of calls] and [no of contacts]) resulting same count.
if u wants to run both qries one after another then the Solution is.... SqlQry 1 Go Sqlqry 2 Go . . . . Try Go Statement in SQL it will help you... Enjoy your coding.. :-D