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

Re: Problem with sql

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: x asasaxax <xanaruto(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with sql
Date: 2008-10-29 05:46:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Tue, Oct 28, 2008 at 11:36:12PM -0300, x asasaxax wrote:
> table_1: product_code, atualization_date
> table_2: id, date, value
> I need to get the value of table 2 that has the greatest date that is minor
> that atualization_date.
> The select should return something like that:
> unique product_codeĀ“s, with their atualization_date and their value

select t1.*,
    (select t2.value from table_2 as t2 where < t1.atualization_date order by desc limit 1)
from table_1 as t1


Linkedin:  /  blog:
jid/gtalk: depesz(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

In response to

pgsql-general by date

Next:From: Joshua D. DrakeDate: 2008-10-29 06:13:20
Subject: Re: Decreasing WAL size effects
Previous:From: David WilsonDate: 2008-10-29 03:43:58
Subject: Re: postgresql and Mac OS X

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