Data Comparison Single Table Question

From: Bryan Emrys <bryan(dot)emrys(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Data Comparison Single Table Question
Date: 2008-04-16 13:34:27
Message-ID: 200804160634.27304.bryan.emrys@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I can handle this outside sql, but it seems like I should be able to do this in sql as well.

1 table: countries.
3 columns: id, name, price

What I'm trying to get is a result of the price differences between every country.

So if the data looks like (ignoring the id field)

Taiwain 30
UK 50
US 40

I'm trying to build a matrix that looks like:
Taiwan UK US
Taiwan 0 -20 -10
UK 20 0 10
US 10 -10 0

Any pointers would be appreciated.

Bryan

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vivek Khera 2008-04-16 14:27:49 Re: How to find double entries
Previous Message Gerardo Herzig 2008-04-16 12:01:02 Re: Multiple databases