E
E
EVOSandru62015-09-30 06:22:32
PostgreSQL
EVOSandru6, 2015-09-30 06:22:32

How to make dynamic limit in postgres query?

Good afternoon,
The following request is not processed:

UPDATE m_hotels set firm_id = 2 where id in (select id from m_hotels order by random() limit (count(m_hotels) / 3 ));

ERROR: aggregate functions are not allowed in LIMIT
LINE 1: ...(select id from m_hotels order by random() limit (count(m_ho...
^
********** Error ***** *****

What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-09-30
@EVOSandru6

But after all, they directly wrote what the error was:
Aggregate functions cannot be used in LIMIT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question