Skip site navigation (1) Skip section navigation (2)

Looking for correct SQL

From: Alexander Pucher <pucher(at)atlas(dot)gis(dot)univie(dot)ac(dot)at>
To: pgsql-novice(at)postgresql(dot)org
Subject: Looking for correct SQL
Date: 2004-10-14 19:46:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

I'm struggling for some time with the following problem:

I have a table like this:

name    key            value
andi    age                23
andi    hometown    boston
tom    age                45
greg    hometown    miami

I would like to get the following through a SQL Select Statement:

name    age    hometown
andy    23        boston
tom      45         NULL
greg      NULL   miami

I thought about a subselect, but could'nt find the clue.

Thanks for any input,
best regards,


pgsql-novice by date

Next:From: Michael FuhrDate: 2004-10-14 19:46:47
Subject: Re: copy error
Previous:From: Keith WorthingtonDate: 2004-10-14 18:12:49
Subject: copy error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group