Re: need help

From: Carlos Chapi <carlos(dot)chapi(at)2ndquadrant(dot)com>
To: denero team <deneroteam(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: need help
Date: 2013-02-21 19:56:46
Message-ID: CAAk_w-qkwCtrKP5FH4Xro0=xdKj=LAnBdG4ZaV1s7fd5_eRSRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

Maybe this query can help you

SELECT p.name, l.name
FROM location l
INNER JOIN product_move m ON m.source_location = location.id
INNER JOIN product p ON m.product_id = p.id
WHERE p.id = $product_id
AND m.datetime < $given_date
ORDER BY datetime DESC LIMIT 1

It will return the name of the product and the location for a given id and
date.

2013/2/21 denero team <deneroteam(at)gmail(dot)com>

> Hi All,
>
> I need some help for my problem.
> Problem :
> I have following tables
> 1. Location :
> id, name, code
> 2. Product
> id, name, code, location ( ref to location table)
> 2. Product_Move
> id, product_id ( ref to product table), source_location (ref to
> location table) , destination_location ( ref to location table) ,
> datetime ( date when move is created)
>
> now i want to know for given period of dates, where is the product
> actually.
>
> can anyone help me ??
>
> Thanks,
>
> Dhaval
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

  • need help at 2013-02-21 17:36:00 from denero team

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message denero team 2013-02-21 20:20:17 Re: need help
Previous Message denero team 2013-02-21 17:36:00 need help