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

Re: Subselect returning 2 columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Francesc Leveque <webmaster(at)loroadictos(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Subselect returning 2 columns
Date: 2004-05-07 01:26:33
Message-ID: 26990.1083893193@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Francesc Leveque <webmaster(at)loroadictos(dot)com> writes:
> Is correct to do something like?:

> SELECT row1,row2 FROM mytable
> WHERE (row1,row3) IN
> (SELECT row1 as p1,MAX(row3) as p2 FROM mytable
> WHERE row3 <= current_date
> GROUP BY row1)

Sure.

> I mean, I don't see documentation about subselects returning more than 
> one column, but it seems to work...

http://www.postgresql.org/docs/7.4/static/functions-subquery.html#AEN12497

			regards, tom lane

In response to

pgsql-sql by date

Next:From: Martin KuriaDate: 2004-05-07 06:47:35
Subject: Re: SUM() & GROUP BY
Previous:From: Andrei BintintanDate: 2004-05-06 13:06:11
Subject: Re: not really SQL but I need info on BLOBs

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