Re: select count(*);

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: select count(*);
Дата
Msg-id CA+bJJbxtLorjbHpobQBYWPSKhf0acjRiSaG5W55Ts7RBFYSYAQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: select count(*);  (Marc Mamin <M.Mamin@intershop.de>)
Список pgsql-general
Hi Marc:

On Thu, Jun 11, 2015 at 4:17 PM, Marc Mamin <M.Mamin@intershop.de> wrote:
>>But COUNT(*)
>>does have meaning - it means "the number of rows".
> which rows? :-)

Well, docs could use a little polish there, as the select page says """

Compatibility

Of course, the SELECT statement is compatible with the SQL standard.
But there are some extensions and some missing features.

Omitted FROM Clauses

PostgreSQL allows one to omit the FROM clause. It has a
straightforward use to compute the results of simple expressions:

SELECT 2+2;

 ?column?
----------
        4

Some other SQL databases cannot do this except by introducing a dummy
one-row table from which to do the SELECT.
""""

Old time users have grown used to use it without questioning, and I
think it's sometimes needed to call functions, but some words along
the "a magic one row zero columns table is used when it is omited",
which is what it seems to be done, would be nice.

And, as I said, * only means the columns in a select, I think on no
from Pg may be generating a fake one row table to satisfy the
requirements ( maybe not, but is one easy way to make this work given
how select is explained to work in the docs ).

Francisco Olarte.


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

Предыдущее
От: Yves Dorfsman
Дата:
Сообщение: Re: select count(*);
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: select count(*);