Most efficent way to limit rows returns from union query- TSQL
Posted
by
stephen776
on Stack Overflow
See other posts from Stack Overflow
or by stephen776
Published on 2010-12-23T13:46:21Z
Indexed on
2010/12/23
13:54 UTC
Read the original article
Hit count: 201
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"
© Stack Overflow or respective owner