Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine two querys 1

Status
Not open for further replies.

simma

Programmer
Sep 11, 2001
398
US
Hello,
How do I combine these two queries so that I dont have to use #temp table.The whole purpose is to get WorkGroup_Id from agent summary table for first select statement resultset


create table #attempts
(cnt int,
ent varchar(20),edt datetime)
insert into #attempts
SELECT COUNT(*)as attempts, enteredby,enterdate FROM t_srvcoli_attempts
WHERE EnterDate BETWEEN '04/01/2005' and '04/02/2005'
group by enteredby,enterdate
order by enteredby,enterdate

select distinct s.workgroup_id,a.ent,a.cnt from #attempts a
inner join AgentSummary s
on s.user_id=a.ent
where s.workgroup_id<>0
AND WorkGroup_Id IN ( 9, 10)
drop table #attempts
 
Code:
select distinct s.workgroup_id,a.enteredby,a.attempts
From
(SELECT COUNT(*)as attempts, enteredby,enterdate FROM t_srvcoli_attempts
WHERE EnterDate BETWEEN '04/01/2005' and '04/02/2005' 
group by enteredby,enterdate
order by enteredby,enterdate) a
inner join AgentSummary s on s.user_id=a.ent
where s.workgroup_id<>0
AND WorkGroup_Id IN ( 9, 10)

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Excellent...works..
Thanks checkai!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top