how to include single value from another table
Posted: Mon 06 Apr 2015 03:30
I have two tables master table1 and detail table2
Table1 structure:
table1_id integer,
name varchar(20),
description varchar(50)
Table2 structure
table2_id integer,
table1_id integer,
price numeric(7,2),
Price_date date
I know how to link between them using join but the problem is that I want only to get the most recent price record linked to Table1 not all prices. in other words I dont want duplicates from table "Table2" but only one records contain the most recent price.
how I should write that SQL ?
Table1 structure:
table1_id integer,
name varchar(20),
description varchar(50)
Table2 structure
table2_id integer,
table1_id integer,
price numeric(7,2),
Price_date date
I know how to link between them using join but the problem is that I want only to get the most recent price record linked to Table1 not all prices. in other words I dont want duplicates from table "Table2" but only one records contain the most recent price.
how I should write that SQL ?