troubleshooting Question

How to get results in order of second query

Avatar of abgail
abgail asked on
Microsoft SQL Server 2005
5 Comments1 Solution229 ViewsLast Modified:
I have these 2 queries that currently order the results by tic, and I need the results ordered by the results of the 2nd query.  

insert into table3 (field1, field2,field3, field4, column2, column3)
select '3352', 0,'top tic',0,tic,a.idnumber from
(select top 10 tic, a.idnumber from table1 a inner join table2 b on a.idnumber = b.idnumber
where custfield = '3352' and ratecode >= '7'  group by a.tic, a.idnumber
order by count(distinct tic) desc ) a

update table3 set column4 = (select count(distinct idnumber) from table1 where tic = column3
and custfield  = '3352' and field3 = 'top tic')  where field1 = '3352' and field3 = 'top tic'
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros