Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2012
    Posts
    1

    Unanswered: variable with TOP N command

    Dear all,
    if I would like to select top 10 records for each group (according to some attribute id) I make a follow querry:

    SELECT ELEV, ID_region
    FROM tab
    WHERE ELEV IN (
    SELECT TOP 10 ELEV
    FROM tab as S
    WHERE S.ID_region = tab.ID_region
    ORDER BY ELEV DESC
    );


    Is there any way to replace the TOP parameter value of 10 with variable X wich is taken from some attribute of my table and which is fixed or dynamically computed for each group of separation?


    cheers,
    Przemek

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    I used to do this by using the form to edit the query sql before it got run.

    John M Reynolds
    John M Reynolds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •