purejamie
asked on
SQL Matching between two tables
Hi there,
Hopefully this is another simple SQL (2008) question!
I have two tables, table_1 and table_2. These tables have a column in common, product_code. Also there is a column called price_when_sold in both tables.
I would like to find product_code's from table 1 that are also in table 2, then sum the price_when sold in table 1 for that product_code, then also sum the price_when_sold in table 2 for that product_code. Then present them as columns in the same results.
Hopefully this is simple and quick for someone! :)
Cheers,
Jamie.
Hopefully this is another simple SQL (2008) question!
I have two tables, table_1 and table_2. These tables have a column in common, product_code. Also there is a column called price_when_sold in both tables.
I would like to find product_code's from table 1 that are also in table 2, then sum the price_when sold in table 1 for that product_code, then also sum the price_when_sold in table 2 for that product_code. Then present them as columns in the same results.
Hopefully this is simple and quick for someone! :)
Cheers,
Jamie.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you please post teh a sample result... if above post is not what you want...
ASKER
Hi There,
The first answer has got me pretty much where I want, I just need to refine it slightly if that is OK. Each table also has a Sale_Date column. I would like to group the results into quarters lke
Product Code Quarter 1 Quarter 2
Table 1 Table 2 Table 1 Table 2
12343242343 $150 $130 $123 $231
Also, could I show only when table 1 and table 2 totals match please..
Many thanks for your help so far... Promise this is the last part of the question!
Cheers,
Jamie.
The first answer has got me pretty much where I want, I just need to refine it slightly if that is OK. Each table also has a Sale_Date column. I would like to group the results into quarters lke
Product Code Quarter 1 Quarter 2
Table 1 Table 2 Table 1 Table 2
12343242343 $150 $130 $123 $231
Also, could I show only when table 1 and table 2 totals match please..
Many thanks for your help so far... Promise this is the last part of the question!
Cheers,
Jamie.
how come you have 4 sale for one item? you said two tables two sale columns!...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.