From: | Bjørn T Johansen <btj(at)havleik(dot)no> |
---|---|
To: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem writing sql statement.... |
Date: | 2007-02-16 07:44:21 |
Message-ID: | 20070216084421.1c49f48a@foxhound |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Not exactly what I want... I don't know the date or id, I just need to find all rows that have the same date
and the same id..
BTJ
On Thu, 15 Feb 2007 16:46:21 -0600
Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> wrote:
> -----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-----
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
From | Date | Subject | |
---|---|---|---|
Next Message | MG | 2007-02-16 07:59:40 | Re: WARNING: some databases have not been vacuumed in 1953945422 transactions |
Previous Message | Gene | 2007-02-16 07:32:26 | rule creating infinite recursion not sure why |