문제

By using SQL Server 2000, I want to create a output data template as shown below using data's in table1 and table2

Output Data_Template

Unit1   | Sale_value_1  | Sale_value_2|
-------------------------------------------    
chart1  | 25             |12|
chart2  | 30             |0|
chart3  | 56             |0|
chart4  | 41             |98|

Table1

Date        |Unit1  |Sale_value_1|
------------------------------------    
2/11/2014   |chart1 |25|
2/11/2014   |chart2 |30|
2/11/2014   |chart3 |56|
2/11/2014   |chart4 |41|

Table2

Date        |Unit1  |Sale_value_2|
-----------------------------------    
2/11/2014   |chart1 |12|
2/11/2014   |chart2 |0|
2/11/2014   |chart3 |0|
2/11/2014   |chart4 |98|
도움이 되었습니까?

해결책

This SQL Fiddle demonstrates the below query:

SELECT t1.Unit1, t1.Sale_value_1, t2.Sale_value_2 
FROM Table1 as t1
INNER JOIN Table2 as t2 ON t1.Unit1 = t2.Unit1
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top