From: | Andy Colson <andy(at)squeakycode(dot)net> |
---|---|
To: | "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca> |
Subject: | Re: Help with join syntax sought |
Date: | 2009-05-19 21:29:45 |
Message-ID: | 4A1324C9.3040101@squeakycode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
James B. Byrne wrote:
> On Tue, May 19, 2009 17:02, Andy Colson wrote:
>
>> so: select max(name), type from food group by type
>> works cuz we only get one name (the max name) back for each type.
>>
>> or: select name, type from food group by type, name
>> which in our example is kinda pointless, but still, give us the
>> distinct
>> items for "type, name".
>
> Thanks. I think I am beginning to see this. So, if there are more
> than one type for a given currency code and I do not select and
> group by type then the having count(whatever) = 1 means that these
> rows are not selected either. Is that correct?
>
>
I'm not familiar with your data, and I didn't study your sql very hard.
I'm not sure what this will do:
HAVING
COUNT(fxr.currency_code_quote) = 1
The only time I have ever used HAVING is like:
select name from something group by name having count(*) > 1
to find duplicate name's.
you're group by is on 5 fields, but the count is only on one.... so...
If a count is in the select part (like select count(name) from stuff)
it only counts when name is not null... so maybe that having is saying
count where currency_code_quote is not null and there is only one record
per group... I dunno.
-Andy
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Colson | 2009-05-19 21:34:24 | Re: Help with join syntax sought |
Previous Message | Pal, Dipali (UMKC-Student) | 2009-05-19 21:16:33 | Direct I/O and postgresql version |