Re: Can I get the number of results plus the results with a single query?
От
Wim Bertels
Тема
Re: Can I get the number of results plus the results with a single query?
Дата
Msg-id
c26e951ed0b6074536deef1a94f2a0b30c35f506.camel@ucll.be
Ответ на
Список
Дерево обсуждения
Can I get the number of results plus the results with a single query? Perry Smith <pedz@easesoftware.com>
Re: Can I get the number of results plus the results with a single query? "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Can I get the number of results plus the results with a single query? Bryn Llewellyn <bryn@yugabyte.com>
Re: Can I get the number of results plus the results with a single query? "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Can I get the number of results plus the results with a single query? Bryn Llewellyn <bryn@yugabyte.com>
Re: Can I get the number of results plus the results with a single query? "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Can I get the number of results plus the results with a single query? Wim Bertels <wim.bertels@ucll.be>
Re: Can I get the number of results plus the results with a single query? "David G. Johnston" <david.g.johnston@gmail.com>
Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query? Perry Smith <pedz@easesoftware.com>
Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query? Rob Sargent <robjsargent@gmail.com>
Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query? "Walter Dörwald" <walter@livinglogic.de>
Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query? David Rowley <dgrowleyml@gmail.com>
Perry Smith schreef op ma 15-08-2022 om 08:49 [-0500]: > I like to have what I call “baby sitting” messages such as “Completed > 15 out of 1023”. To do this, I need the number of results a query > returns but I also need the results. > > Currently I’m doing this with two queries such as: > > SELECT COUNT(*) FROM table WHERE …. expression … > SELECT * FROM table WHERE …. expression … > > But this requires two queries. Is there a way to do the same thing > with just one query somehow? > > I’ve been toying with row_number() and then sort by row_number > descending and pick off the first row as the total number. if i understand your question: count(*) over () (u can use aggregate functions as well, not only window functions) mvg, Wim
В списке pgsql-general по дате отправления