sql - select TOP n Rows from table where n is in another table? -


how can achieve without using dynamic sqlquery?

i have query,

select top n mytable id = @id 

to value of n,

select ncount myanothertable id = @id 

can use row_index() this?

try this....but make sure select ncount return single row.....if not select top row ncount

select top(select top 1 ncount myanothertable id = @id) * mytable id = @id 

sqlfiddle: http://www.sqlfiddle.com/#!3/75c76/1


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -