Re: select count(*);

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: "'Chris Mair'" <chris(at)1006(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: select count(*);
Date: 2015-06-11 14:05:11
Message-ID: B6F6FD62F2624C4C9916AC0175D56D8828BE7FD1@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > select *;
> > ----------
> > ERROR: SELECT * with no tables specified is not valid
> >
> > select count(*);
> > ----------------
> > 1
> >
> > Is this a must? and why 1?
>
> Hi,
>
> regarding the "why 1" part:
>
> I think that if we accept that
>
> chris=> select 'foo';
> ?column?
> ----------
> foo
> (1 row)
>
> returns 1 row, then naturally
>
> chris=> select count('foo');
> count
> -------
> 1
> (1 row)
>
> should give a count of 1...
>
> The * might be a bit tricky, though,
> since 'select *;' doesn't work.

That's the point. * has no meaning without FROM

Marc

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoff Winkless 2015-06-11 14:13:06 Re: select count(*);
Previous Message Francisco Olarte 2015-06-11 14:04:50 Re: Planner cost adjustments