var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: merge two tables
Hello, I need your expert help:
I have two tables (ship2005 and ship2006) all with same structure
I have to merge them together, and add some other columns from other tables
Custmstr (director) and stylemstr (style) based on Sold_to
In the format so I’m able to see 2005 week, 2006 week, 2005 unit, 2006 unit, 2005 dollars, 2006 dollars and so on.
This one is working, but forever…
where Custmstr.Sold_to *= ship2005.Sold_to
and Custmstr.Sold_to *= ship2006.Sold_To
and stylmstr.style_num *= ship2005.style_number
and stylmstr.style_num *= ship2006.style_number
And another thing: how can I populate the Year column for both?
Thank you very much
Please provide some sample output so we can see where you want to go with this.
Sold_to Director Style Year Week Units05 Units06 Dollars05 Dollars06
18 6 8433 2006 1 6 67
24 6 2599 2006 1 2 30
24 6 2604 2006 1 1 17
24 6 2604 2005 1 1 13
24 6 2788 2006 1 1 15
Use a UNION query to combine the two datasets.
Use a CROSSTAB query to generate the layout you want, with separate headers for each year. Books Online has an excellent explanation of how to create a CROSSTAB query using TSQL CASE statements.
Thank you, done reading CROSSTAB ...all works fine.