pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Iain <iain@mst.co.jp>
To: Abdul Wahab Dahalan <wahab@mimos.my>
To: pgsql-sql@postgresql.org
Subject: Re: How to get Rows Count
Date: Mon, 1 Mar 2004 12:58:09 +0900
Message-ID: <022701c3ff41$69646490$7201a8c0@mst1x5r347kymb> (raw)
References: <40429AA1.4060905@mimos.my>

howabout:

select sum(case when c =  '*' then 0 else 1 end) as count_not_star from
tablename

If you want to process all records but only count thouse without a * in c
then this will do the trick.

regards
iain
----- Original Message ----- 
From: "Abdul Wahab Dahalan" <wahab@mimos.my>
To: <pgsql-sql@postgresql.org>
Sent: Monday, March 01, 2004 11:06 AM
Subject: [SQL] How to get Rows Count


> >
> >
> >a       b      d    c
> >01      02     b    *
> >01      02     a    *
> >02      03
> >02      04     b    *
> >02      04     a    *
> >03      05
> >04      06
> >
> If I've a table like above, how do I make a query to get rows count that
> doesnt have '*' in it.
>
> Can we have other queries than this : Select count(c) from tablename
> where c !='*';
> or Select count(c) from tablename where c <> '*';
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)




view thread (2+ messages)

Message-ID: <022701c3ff41$69646490$7201a8c0@mst1x5r347kymb>
Permalink:  ../022701c3ff41$69646490$7201a8c0@mst1x5r347kymb/
Also on:    postgresql.org/message-id/022701c3ff41$69646490$7201a8c0@mst1x5r347kymb

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: iain@mst.co.jp, wahab@mimos.my
  Subject: Re: How to get Rows Count
  In-Reply-To: <022701c3ff41$69646490$7201a8c0@mst1x5r347kymb>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox