What I want is to get this result:
Result Table on date example 2007-01-05:
Code | Name | Qty | Value
100 | Name A | 10 | 123
Result Table on date example 2007-02-05:
Code | Name | Qty | Value
100 | Name A | 8 | 300
200 | Name B | 3 | 100
And so on…
So, Table 1 is primary and Table B is some sort of history what happened with some “Code” on some dates… What I want is to get result on certain date with right QTY on that date and also right Value on that date (or most nearest value).
What I want is to get this result:
Result Table on date example 2007-01-05:
Code | Name | Qty | Value
100 | Name A | 10 | 123
Result Table on date example 2007-02-05:
Code | Name | Qty | Value
100 | Name A | 8 | 300
200 | Name B | 3 | 100
And so on…
So, Table 1 is primary and Table B is some sort of history what happened with some “Code” on some dates… What I want is to get result on certain date with right QTY on that date and also right Value on that date (or most nearest value).
Tahnks…
Use a JOIN condition, like
SELECT code, name, qty, value FROM b INNER JOIN a USING (code) WHERE date = ‘2007-02-05’;