Re: [GENERAL] Group by with insensitive order

2011-01-19 Thread Aram Fingal
> Easy way is something like > > SELECT LEAST(drug1, drug2), GREATEST(drug1, drug2), AVG(response) > FROM data > GROUP BY 1, 2 > > though it'd be a PITA to scale that to more than 2 drugs. > > regards, tom lane Thanks, Tom and Hubert, who said the same thing. For the for

Re: [GENERAL] Group by with insensitive order

2011-01-19 Thread Tom Lane
Aram Fingal writes: > Suppose I'm doing a group by query like the following: > SELECT drug1, drug2, AVG(response) > FROM data > GROUP BY drug1, drug2 > The problem is that the same drug may appear sometimes as drug1 and sometimes > as drug2. So, for example, the combination "aspirin, acetaminop

Re: [GENERAL] Group by with insensitive order

2011-01-19 Thread hubert depesz lubaczewski
On Wed, Jan 19, 2011 at 03:37:58PM -0500, Aram Fingal wrote: > Suppose I'm doing a group by query like the following: > > SELECT drug1, drug2, AVG(response) > FROM data > GROUP BY drug1, drug2 > > The problem is that the same drug may appear sometimes as drug1 and > sometimes as drug2. So, for e