Search Postgresql Archives

Re: Check if there 6 last records of same type without gaps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sandor, this has worked, thank you -

On Tue, Sep 6, 2016 at 3:35 PM, Sándor Daku <daku.sandor@xxxxxxxxx> wrote:

Of course you need the played field you relied on it in the order by clause. You can use the result of a select in a from clause of another select.

SELECT SUM(skips) from (SELECT CASE WHEN action="" THEN 1 ELSE 0 END as skips, played
         FROM words_moves
         WHERE gid = 3
         ORDER BY played DESC
         LIMIT 6) as skipscount;  


words=> SELECT SUM(skips) from (SELECT CASE WHEN action="" THEN 1 ELSE 0 END as skips, played
words(>          FROM words_moves
words(>          WHERE gid = 3
words(>          ORDER BY played DESC
words(>          LIMIT 6) as skipscount;
 sum
-----
   6
(1 row)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux