Search code examples
sqlmonetdb

LIMIT and OFFSET in Subquery for MonetDB Alternative


So I am trying to execute the following statement in MonetDB:

SELECT AVG(col0), VAR_SAMP(col0) FROM (SELECT * FROM table LIMIT 4 OFFSET 6) as foo;

I know that this is not supported in MonetDB, but I was wondering whether anyone had an alternative.

Thank you! I'd really appreciate it!


Solution

  • I think I solved my own problem!

    SELECT AVG(col0) FROM (SELECT col0, ROW_NUMBER() OVER() as rnum FROM table) as foo WHERE rnum > 6 AND rnum < 11;
    

    I can use a script to alter the rnum parameters and get the behavior I want.

    Thanks!