Re: select count(*) and limit

Поиск
Список
Период
Сортировка
От Oscar Rodriguez Fonseca
Тема Re: select count(*) and limit
Дата
Msg-id 20060518132753.6666a4d6@vrlap.localvrnet
обсуждение исходный текст
Ответ на select count(*) and limit  (Verena Ruff <lists@triosolutions.at>)
Ответы Re: select count(*) and limit  (Verena Ruff <lists@triosolutions.at>)
Список pgsql-novice
El día Thu, 18 May 2006 12:51:10 +0200
Verena Ruff <lists@triosolutions.at> escribió:

> sometimes I have queries with a LIMIT statement. Now I'd like to present
> the user the returned records and inform him how many records there are
> if there was no LIMIT statement. Is it possible to get all neccessary
> information with one query?
> This works:
> SELECT * FROM table LIMIT 20
> SELECT count(*) FROM table
> But is it possible to have one query returning both, the records and the
> count?

A surely _INEFFICIENT_ way of doing it:


SELECT t.*,c.count FROM table AS t FULL OUTER JOIN (SELECT count(*) FROM
table) AS c ON true LIMIT 20;

This will add a 'count' column at the end of each row (with the same value for all).

But I do not get the point of the query.

Regards,

--
Oscar

В списке pgsql-novice по дате отправления:

Предыдущее
От: Oscar Rodriguez Fonseca
Дата:
Сообщение: Re: selecting un-ordered rows
Следующее
От: Verena Ruff
Дата:
Сообщение: Re: select count(*) and limit