sql - SELECT TOP ... FROM UNION -
what best way select top n records union of 2 queries?
i can't do
select top n ... (select ... table1 union select ... table2)
because both queries return huge results need every bit of optimization possible , avoid returning everything. same reason cannot insert results #temp table first either.
i can't use set rowcount n
either because may need group results , command limit number of grouped rows, , not underlying row selections.
any other ideas? thanks!
use top keyword inner queries also:
select top n ... (select top n... table1 union select top n... table2)
Comments
Post a Comment