Re: Diffcult query

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Diffcult query
Дата
Msg-id 200303211145.58768.josh@agliodbs.com
обсуждение исходный текст
Ответ на Diffcult query  ("Dan Winslow" <d.winslow@cox.net>)
Список 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 по дате отправления:

Предыдущее
От: Sethi Tarun-ETS017
Дата:
Сообщение: SQL
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: