Re: Problem writing sql statement.... - Mailing list pgsql-general

From Ron Johnson
Subject Re: Problem writing sql statement....
Date
Msg-id 45D4E2BD.60104@cox.net
Whole thread Raw
In response to Problem writing sql statement....  (Bjørn T Johansen <btj@havleik.no>)
Responses Re: Problem writing sql statement....  (Bjørn T Johansen <btj@havleik.no>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/15/07 15:13, Bjørn T Johansen wrote:
> I have a table that I want to find rows that have the same value
> in two fields, e.g. all rows that have the same date and also the
>  same productionid... How do I write such an sql statement?

If I understand your question:

SELECT FIELD_1, FIELD_2, COUNT(*)
FROM A_TABLE
WHERE SOME_DATE = 'yyyy-mm-dd'
  AND PRODUCTIONID = nnnn
GROUP BY FIELD_1, FIELD_2
HAVING COUNT(*) > 1;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFF1OK9S9HxQb37XmcRAhC9AJ9YKyb2HRhr+FAaWQluMG86lyV6egCgu0LU
3KT/s+eq5KKHSYDnpRKuyu4=
=SgpW
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Where art thou pg_clog?
Next
From: Jeff Ross
Date:
Subject: invalid regular expression: invalid backreference number