public inbox for [email protected]
help / color / mirror / Atom feedRe: COUNTs don't add up
4+ messages / 3 participants
[nested] [flat]
* Re: COUNTs don't add up
@ 1970-01-01 00:00 omid omoomi <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: omid omoomi @ 1970-01-01 00:00 UTC (permalink / raw)
To: [email protected]; pgsql-general
hi ,
try this :
select species2, count(*) from homol_loclink group by species2;
it will show you.
Regards
Omid
>From: Alexander Turchin <[email protected]>
>To: PostgreSQL Mailing List <[email protected]>
>Subject: [GENERAL] COUNTs don't add up
>Date: Mon, 23 Jul 2001 15:32:04 -0400
>
>Hello all,
>
>I have a database where (I believe; the database was not made by me) one
>of the columns contains only two values: A or B. When I count all the
>rows in the database I get X; when I count the rows containing A or B in
>that column I get X-2; when I count the rows containing neither A nor B
>I get 0. Any explanation (hopefully, again, I am doing something wrong
>:)?
>
>The actual queries are found below.
>
>Thanks!
>
>Alex
>
>aturchin=# SELECT COUNT(*) FROM homol_loclink
>aturchin-# WHERE (species2 = 'Mus musculus') OR
>aturchin-# (species2 = 'Rattus norvegicus');
> count
>-------
> 7110
>(1 row)
>
>aturchin=# SELECT COUNT(*) FROM homol_loclink;
> count
>-------
> 7112
>(1 row)
>
>aturchin=# SELECT COUNT(*) FROM homol_loclink
>aturchin-# WHERE (species2 <> 'Mus musculus') AND
>aturchin-# (species2 <> 'Rattus norvegicus');
> count
>-------
> 0
>(1 row)
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to [email protected] so that your
>message can get through to the mailing list cleanly
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
^ permalink raw reply [nested|flat] 4+ messages in thread
* COUNTs don't add up
@ 2001-07-23 19:32 Alexander Turchin <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Turchin @ 2001-07-23 19:32 UTC (permalink / raw)
To: pgsql-general
Hello all,
I have a database where (I believe; the database was not made by me) one
of the columns contains only two values: A or B. When I count all the
rows in the database I get X; when I count the rows containing A or B in
that column I get X-2; when I count the rows containing neither A nor B
I get 0. Any explanation (hopefully, again, I am doing something wrong
:)?
The actual queries are found below.
Thanks!
Alex
aturchin=# SELECT COUNT(*) FROM homol_loclink
aturchin-# WHERE (species2 = 'Mus musculus') OR
aturchin-# (species2 = 'Rattus norvegicus');
count
-------
7110
(1 row)
aturchin=# SELECT COUNT(*) FROM homol_loclink;
count
-------
7112
(1 row)
aturchin=# SELECT COUNT(*) FROM homol_loclink
aturchin-# WHERE (species2 <> 'Mus musculus') AND
aturchin-# (species2 <> 'Rattus norvegicus');
count
-------
0
(1 row)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: COUNTs don't add up
@ 2001-07-23 20:27 Alexander Turchin <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Turchin @ 2001-07-23 20:27 UTC (permalink / raw)
To: [email protected]; pgsql-general
Yes, that turns out to be exactly the case - should have thought of it myself (of
course :).
Thanks!
Alex
[email protected] wrote:
> Could species2 be null? If so, I don't think those rows would appear when you
> test for <> 'somevalue'.
>
> Alexander Turchin <aturchin%[email protected]> on 07/23/2001
> 03:32:04 PM
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: COUNTs don't add up
@ 2001-07-23 20:37 Len Morgan <[email protected]>
parent: Alexander Turchin <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Len Morgan @ 2001-07-23 20:37 UTC (permalink / raw)
To: Alexander Turchin <[email protected]>; pgsql-general
Could there be two rows that have NULL is the value? They don't "count" as
far as I know. You can try:
SELECT count(*) from homol_loclink WHERE species2 IS NULL
to verify this.
len morgan
----- Original Message -----
From: "Alexander Turchin" <[email protected]>
To: "PostgreSQL Mailing List" <[email protected]>
Sent: Monday, July 23, 2001 2:32 PM
Subject: [GENERAL] COUNTs don't add up
> Hello all,
>
> I have a database where (I believe; the database was not made by me) one
> of the columns contains only two values: A or B. When I count all the
> rows in the database I get X; when I count the rows containing A or B in
> that column I get X-2; when I count the rows containing neither A nor B
> I get 0. Any explanation (hopefully, again, I am doing something wrong
> :)?
>
> The actual queries are found below.
>
> Thanks!
>
> Alex
>
> aturchin=# SELECT COUNT(*) FROM homol_loclink
> aturchin-# WHERE (species2 = 'Mus musculus') OR
> aturchin-# (species2 = 'Rattus norvegicus');
> count
> -------
> 7110
> (1 row)
>
> aturchin=# SELECT COUNT(*) FROM homol_loclink;
> count
> -------
> 7112
> (1 row)
>
> aturchin=# SELECT COUNT(*) FROM homol_loclink
> aturchin-# WHERE (species2 <> 'Mus musculus') AND
> aturchin-# (species2 <> 'Rattus norvegicus');
> count
> -------
> 0
> (1 row)
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to [email protected] so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-07-23 20:37 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1970-01-01 00:00 Re: COUNTs don't add up omid omoomi <[email protected]>
2001-07-23 19:32 COUNTs don't add up Alexander Turchin <[email protected]>
2001-07-23 20:37 ` Len Morgan <[email protected]>
2001-07-23 20:27 Re: COUNTs don't add up Alexander Turchin <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox