Ruby 1.9.2 / rails 3.1 / deploy to hero β posgresql
Hey. When the number of lines related to the object moves by a certain amount, I want to discard every nth line. This is simply because the rows are used (partially) to display data for graphical display, therefore, as soon as the number of rows returned exceeds 20, it is useful to return every second, etc.
This question seemed to point in the right direction: ActiveRecord Find - skip records or get every Nth record
Running a mod on a line number makes sense, but is mostly used:
@widgetstats = self.widgetstats.find(:all,:conditions => 'MOD(ROW_NUMBER(),3) = 0 ')
does not work, it returns an error:
PGError: ERROR: window function call requires an OVER clause
And any attempt to solve this, for example, basing the syntax of the OVER clause on the things that I see in the answer to this question:
PostgreSQL line numbering
ends with syntax errors and I cannot get the result.
Am I missing a more obvious way to efficiently return every nth task, or if I am on the right path, any pointers on the path? Obviously, the return of all data and their fixation in rails is subsequently possible, but terribly inefficient.
Thanks!