pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: lakradimarwan@gmail.com
Subject: BUG #15904: ERROR:  argument of LIMIT must not contain variables
Date: Thu, 11 Jul 2019 15:05:29 +0000
Message-ID: <15904-462bf7dbd5e7d11d@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15904
Logged by:          Lakradi Marwan
Email address:      lakradimarwan@gmail.com
PostgreSQL version: 11.4
Operating system:   Mac OS X - High Sierra
Description:        

Good afternoon,

I would like to be able to conditionally limit my query (without python
script) based on a column value (for dynamic limit)

See example below:

SELECT summary.* 
FROM
(
SELECT 
 	id, 
 	amount, date,
 	SUM(amount) OVER (PARTITION BY customer ORDER BY date, id) as
amount_summed
 FROM 
 	customer
ORDER BY date DESC, id DESC
) AS summary
LIMIT CASE WHEN summary.amount_summed >= 0 THEN summary.id ELSE NULL END;

The limit doesn't work, whereas :
 - LIMIT CASE WHEN 100.0 >= 0 THEN 10 ELSE NULL END;
works well !

I don't see the point, what is the main difference between
summary.amount_summed which is a float, and directly pass 100.0 ?



view thread (5+ messages)  latest in thread

Message-ID: <15904-462bf7dbd5e7d11d@postgresql.org>
Permalink:  ../15904-462bf7dbd5e7d11d@postgresql.org/
Also on:    postgresql.org/message-id/15904-462bf7dbd5e7d11d@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, lakradimarwan@gmail.com
  Subject: Re: BUG #15904: ERROR:  argument of LIMIT must not contain variables
  In-Reply-To: <15904-462bf7dbd5e7d11d@postgresql.org>
  References: <15904-462bf7dbd5e7d11d@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox