I have a problem dealing with the following construct:
SELECT *
FROM X
INNER JOIN
(
SELECT TOP (X.IntegerAmount) *
FROM Y
) AS Z ON X.ID = Z.X_ID
Is there a solution for this problem?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t parameterise TOP with the value from another table
You can use a ranking function
Or you’d have to make the derived query a UDF with a @topparameter
Note: you need an ORDER BY anyway
There are probably better ways to do what you actually want: this is answer to the what you actually asked which probably isn’t the same thing…