I have two tables :
我有两张桌子:
TMP_Turnover
TMP_Turnover
Year Code | CODE_DEVISE | CODE_AFFILIATE| Period |Turnover
TMP_Outstanding
TMP_Outstanding
Year Code |CODE_DEVISE |CODE_AFFILIATE |Frequency |Period |Outstanding
How to comine the results of the tables in one table Main
如何在一个表Main中查看表的结果
Year Code |CODE_DEVISE |CODE_AFFILIATE |Frequency |Period |Outstanding|Turnover
I tried using union but it dosen't return the best results, I'm a newbie with SQL SERVER.
我尝试使用union但它没有返回最好的结果,我是SQL SERVER的新手。
2 个解决方案
#1
0
Use join. For beginner level in sql, check w3schools site, they have good tutorials
使用加入。对于sql中的初学者级别,请查看w3schools网站,他们有很好的教程
#2
0
Use LEFT Join AS below:
使用LEFT加入AS如下:
SELECT
TT.YearCode,
TT.CODE_DEVISE,
TT.CODE_AFFILIATE,
TO.Frequency,
TT.Period,
TO.Outstanding,
TT.Turnover
FROM TMP_Turnover TT
LEFT JOIN TMP_Outstanding TO ON TT.YearCode=TO.YearCode
AND TT.CODE_DEVISE=TO.CODE_DEVISE
AND TT.CODE_AFFILIATE=TO.CODE_AFFILIATE
AND TT.Period=TO.Period
#1
0
Use join. For beginner level in sql, check w3schools site, they have good tutorials
使用加入。对于sql中的初学者级别,请查看w3schools网站,他们有很好的教程
#2
0
Use LEFT Join AS below:
使用LEFT加入AS如下:
SELECT
TT.YearCode,
TT.CODE_DEVISE,
TT.CODE_AFFILIATE,
TO.Frequency,
TT.Period,
TO.Outstanding,
TT.Turnover
FROM TMP_Turnover TT
LEFT JOIN TMP_Outstanding TO ON TT.YearCode=TO.YearCode
AND TT.CODE_DEVISE=TO.CODE_DEVISE
AND TT.CODE_AFFILIATE=TO.CODE_AFFILIATE
AND TT.Period=TO.Period