Re: select count(*); - Mailing list pgsql-general

From Francisco Olarte
Subject Re: select count(*);
Date
Msg-id CA+bJJbxtLorjbHpobQBYWPSKhf0acjRiSaG5W55Ts7RBFYSYAQ@mail.gmail.com
Whole thread Raw
In response to Re: select count(*);  (Marc Mamin <M.Mamin@intershop.de>)
List 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 by date:

Previous
From: Yves Dorfsman
Date:
Subject: Re: select count(*);
Next
From: Adrian Klaver
Date:
Subject: Re: select count(*);