Most efficent way to limit rows returns from union query- TSQL
- by stephen776
Hey guys...I have a simple stored proc with two queries joined with a union
select name as 'result'
from product
where...
union
select productNum as 'result'
from product
where...
I want to limit this to the TOP 10 results...
if i put TOP 10 in each seperate query I get 20 results total.
What is the most efficient way to limit total results to 10? I dont want to do TOP 5 in each because I may end up in a situation where I have something like 7 "names" and 3 "productsNumbers"