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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -