Re: Diffcult query - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Diffcult query
Date
Msg-id 200303211145.58768.josh@agliodbs.com
Whole thread Raw
In response to Diffcult query  ("Dan Winslow" <d.winslow@cox.net>)
List pgsql-sql
Dan,

> Hi folks. This is giving me fits. I feel like it oughta be simple, but
> apparantly its not...I think.

> I need a ( preferably single ) query that will sum the costs for all unique
> pairs of codes, without regard to column order. That is, for summing
> purposes, rows 1 and 3 are identical, and should produce the sum of 8 for
> the unordered pair("aaa","bbb"). It should also, of course, prevent the case
> where ("bbb","aaa") is considered a seperate pair. Any ideas would be much
> appreciated.

It's not simple, because your DB design is poorly normalized.   My first
suggestion would be to make some design changes to your schema.  Is that
possible?

--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: Sethi Tarun-ETS017
Date:
Subject: SQL
Next
From: Stephan Szabo
Date:
Subject: Re: