From: | Jaime Casanova <jaime(at)2ndquadrant(dot)com> |
---|---|
To: | denero team <deneroteam(at)gmail(dot)com> |
Cc: | Carlos Chapi <carlos(dot)chapi(at)2ndquadrant(dot)com>, pgsql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: need help |
Date: | 2013-02-22 03:55:08 |
Message-ID: | CAJKUy5iDuUJNQF5RvX6QLYF9fkdmdkna7MExxL5Z8L9S9sESLw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Feb 21, 2013 at 3:20 PM, denero team <deneroteam(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Russell Keane | 2013-02-22 08:31:26 | Re: need help |
Previous Message | Alexander Gataric | 2013-02-22 03:28:02 | Re: Summing & Grouping in a Hierarchical Structure |