Re: using distinct in a single column to get multiple rows

From: Robert Klemme <shortcutter_at_googlemail.com>
Date: Thu, 22 Sep 2011 22:45:09 +0200
Message-ID: <9e1l30F7q6U1_at_mid.individual.net>



On 21.09.2011 23:11, Lennart Jonsson wrote:
> On 2011-09-21 19:28, Robert Klemme wrote:
> [...]
>> In that case I'd prefer this as it is so much simpler:
>>
>> select userid, title, min(zipcode) as zip_min
>> from myTable
>> group by userid, title
>
> If a user can have several titles it won't work, but that can of course
> be solved by adding an aggregate functions on title.

Right, but the OP is not very specific about the data and from the little he has shown it seems id and title correlate. Even though that would be a denormalized schema...

Kind regards

        robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Received on Thu Sep 22 2011 - 15:45:09 CDT

Original text of this message