Re: select count(*)

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: select count(*)
Дата
Msg-id 20110309125032.20e0f25c.wmoran@potentialtech.com
обсуждение исходный текст
Ответ на select count(*)  (Rajesh Kumar Mallah <mallah.rajesh@gmail.com>)
Ответы Re: select count(*)
Список pgsql-general
In response to Rajesh Kumar Mallah <mallah.rajesh@gmail.com>:

> Dear List ,
>
> if we simply do select count(*) and not specify any table then it gives 1
> eg:
>
> bric=# SELECT count(*)  from job ;
>  count
> -------
>   2380
> (1 row)
>
> bric=# SELECT count(*)  job ;
>  job
> -----
>    1
> (1 row)
>
>
>
> bric=# SELECT count(*)  ;
>  count
> -------
>      1
> (1 row)
>
>
>
> bric=# SELECT count(*)  job_non_exist ;
>  job_non_exist
> ---------------
>              1
> (1 row)
>
> bric=# SELECT count(*)  jo1b ;
>  jo1b
> ------
>     1
> (1 row)
>
> bric=# SELECT count(*)  none ;
> ERROR:  syntax error at or near "none"
> LINE 1: SELECT count(*)  none ;
>
>
> I fail to see any  progression ?

When you don't specify a FROM clause, you get 1 because it's
returning 1 row.  No matter what you alias the result to, it's not going
to change the result, unless of course you try to alias it to an SQL
reserved word, such as "none", without quoting it.  Of course, if you
include the optional AS, it probably makes more sense what's going on:

SELECT count(*) AS jolb;
SELECT count(*) AS none;
SELECT count(*) AS "none";

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

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

Предыдущее
От: "Jaiswal Dhaval Sudhirkumar"
Дата:
Сообщение: Re: ER tool that supports domains and custom types?
Следующее
От: John Edens
Дата:
Сообщение: Re: How to configure for remote TCP/IP client conncections using MS Visual Basic OLE DB calls and PostgreSQL dll's?