BUG #15904: ERROR: argument of LIMIT must not contain variables
| От | PG Bug reporting form | 
|---|---|
| Тема | BUG #15904: ERROR: argument of LIMIT must not contain variables | 
| Дата | |
| Msg-id | 15904-462bf7dbd5e7d11d@postgresql.org обсуждение исходный текст | 
| Ответы | Re: BUG #15904: ERROR: argument of LIMIT must not contain variables | 
| Список | pgsql-bugs | 
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 ?
		
	В списке pgsql-bugs по дате отправления: