Re: select count(*) and limit

Поиск
Список
Период
Сортировка
Искать
От
Oscar Rodriguez Fonseca
Тема
Re: select count(*) and limit
Дата
в 08:27:01
Msg-id
20060518132753.6666a4d6@vrlap.localvrnet
Ответ на
Список
Дерево обсуждения
select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit Oscar Rodriguez Fonseca <info@vraniscci.com>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit Oscar Rodriguez Fonseca <info@vraniscci.com>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit Sean Davis <sdavis2@mail.nih.gov>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit John DeSoi <desoi@pgedit.com>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit Sean Davis <sdavis2@mail.nih.gov>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
Re: select count(*) and limit Sean Davis <sdavis2@mail.nih.gov>
Re: select count(*) and limit Verena Ruff <lists@triosolutions.at>
El día Thu, 18 May 2006 12:51:10 +0200
Verena Ruff  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
FAQ