Re: need help - Mailing list pgsql-sql

From Carlos Chapi
Subject Re: need help
Date
Msg-id CAAk_w-qkwCtrKP5FH4Xro0=xdKj=LAnBdG4ZaV1s7fd5_eRSRw@mail.gmail.com
Whole thread Raw
In response to need help  (denero team <deneroteam@gmail.com>)
Responses Re: need help
List pgsql-sql
Hello,

Maybe this query can help you

SELECT p.namel.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@gmail.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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

pgsql-sql by date:

Previous
From: denero team
Date:
Subject: need help
Next
From: denero team
Date:
Subject: Re: need help