Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id DA53A2E0056 for ; Wed, 16 Apr 2008 10:34:43 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 29848-04 for ; Wed, 16 Apr 2008 10:34:24 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by developer.postgresql.org (Postfix) with ESMTP id DF3F62E004A for ; Wed, 16 Apr 2008 10:34:31 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 76so1356999wra.10 for ; Wed, 16 Apr 2008 06:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date:user-agent:organization:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; bh=XvECLNyg6TivYLiMEwTZ99WIeLIf9k0GnKPwFxiOUws=; b=HQHA1C6jyAfRwfpMQCO61SnqDmfXGf5gwMakhMbXt69dO6H33KFP+ttk7I1Biy23NSok1EvTQVeqxi/lYkQiH7VLdNFYNK9gL3LR4TnTmdO+lp/U5AqgjjcHS4djiEppq/VHhWaFlW/pE1Pu2wOA9Tgvsxxd03UY5hpSyqYtl3U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:organization:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=Ih/Acja4qjOe3UAH2wKQgeK9dkZgfJaMvfmEwTgplZzmwBrE9a9bx191a/xX1YEURoSOHjnvQ/l32ON1oYDdoLnsQ6aOSQAVOyIqX575i+s5Glzi7/lzhhTzp2Pr34harp2mEfNl1VyU3toxtTc3hnl0893yQJqUsJJikvGtP+s= Received: by 10.141.113.6 with SMTP id q6mr5206603rvm.135.1208352868837; Wed, 16 Apr 2008 06:34:28 -0700 (PDT) Received: from ?192.168.1.5? ( [98.207.129.115]) by mx.google.com with ESMTPS id k2sm16355895rvb.6.2008.04.16.06.34.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Apr 2008 06:34:28 -0700 (PDT) From: Bryan Emrys To: pgsql-sql@postgresql.org Subject: Data Comparison Single Table Question Date: Wed, 16 Apr 2008 06:34:27 -0700 User-Agent: KMail/1.9.9 Organization: Andras Hill MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200804160634.27304.bryan.emrys@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/95 X-Sequence-Number: 30634 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