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

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -