Re: need help - Mailing list pgsql-sql

From Jaime Casanova
Subject Re: need help
Date
Msg-id CAJKUy5iDuUJNQF5RvX6QLYF9fkdmdkna7MExxL5Z8L9S9sESLw@mail.gmail.com
Whole thread Raw
In response to Re: need help  (denero team <deneroteam@gmail.com>)
List pgsql-sql
On Thu, Feb 21, 2013 at 3:20 PM, denero team <deneroteam@gmail.com> wrote:
> Hi,
>
> Thanks for replying me. yes you are right at some level for my case.
> but its not what I want. I am explaining you a case by example.
>
[...]
>
> Now I really don't know how to do this.
>
> can you advise me more ?
>

I'm not really sure if you even know what you want, because the
examples you showed were just a:
select * from prodct_move where datetime < $given_date

but from the description you gave before i understood another thing,
so this is my only attempt to get an answer from thin air for you:

SELECT distinct on (p.name) p.name, l.name, datetime
FROM location l
INNER JOIN product_move m ON m.destination_location = l.id
INNER JOIN product p ON m.product_id = p.id
WHERE
m.datetime < '2012-12-31'
ORDER BY p.name, datetime DESC

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación
Phone: +593 4 5107566         Cell: +593 987171157



pgsql-sql by date:

Previous
From: "Alexander Gataric"
Date:
Subject: Re: Summing & Grouping in a Hierarchical Structure
Next
From: Russell Keane
Date:
Subject: Re: need help