I want to store some id's in a variable then to use this variable multiple times wherever I have to use in queries. I used this format as:
DECLARE @aid INT
SELECT @aid = AP.aid
FROM
sub_aminer_paper AP
GROUP BY
AP.aid
HAVING
MIN(p_year) = 1990 AND MAX(AP.p_year) = 2014 AND COUNT(AP.pid) BETWEEN 10 AND 40
SELECT
*
FROM
sub_aminer_paper
WHERE
aid = @aid
But this gives me the result only for any single ID from a list of ID's as I used query to retrieve multiple ID's from table sub_aminer_paper.
Please help and Thanks!
INTcan not store more than one value.