Re: count(1) return 0?
От | Uwe C. Schroeder |
---|---|
Тема | Re: count(1) return 0? |
Дата | |
Msg-id | 200402291733.11848.uwe@oss4u.com обсуждение исходный текст |
Ответ на | Re: count(1) return 0? (Zak McGregor <zak@mighty.co.za>) |
Список | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 What is it you want ? the count of rows matching the criteria ? If so a standard count(*) should do. If the resultset has no rows the count(*) will return 0 as result. On Sunday 29 February 2004 05:02 pm, Zak McGregor wrote: > On Sun, 29 Feb 2004 19:55:15 -0500 > > Bill Moran <wmoran@potentialtech.com> wrote: > > Not really sure I understand what you want, but try something like this: > > > > select case when count(*) > 0 then ''t'' else ''f'' end from ... > > Unfortunately that does not work. When the resultset contains no records > whatsoever, I get no rows at all - so on case...else sort of expression > within the select itself will work. > > What I am looking for is a way to select "0" if no rows are returned, or > the total number of rows returned from the query otherwise. > > Thanks anyways though. > > Ciao > > Zak > > -- > ======================================================================== > http://www.carfolio.com/ Searchable database of 10 000+ car specs > ======================================================================== > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html - -- UC - -- Open Source Solutions 4U, LLC 2570 Fleetwood Drive Phone: +1 650 872 2425 San Bruno, CA 94066 Cell: +1 650 302 2405 United States Fax: +1 650 872 2417 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAQpLXjqGXBvRToM4RAh1CAJ4knBgzklnG+Dmuy+62LNAU3JGqDwCcCxUY w1VAIOauzfpO49QgK42et4c= =/U+x -----END PGP SIGNATURE-----
В списке pgsql-general по дате отправления: