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'