在SQL数据库中,我有两个表要进行比较,以查找和显示Tableau中的更改。
原始数据
Column names:
ID,
Category,
Company,
Description,
Update frequency #,
Time since last update [hours],
Measurement (hours/min)
Original_Sample_data:
ACC-1-Nike, ACC, Nike, shoes with acc, 12, 3, hours
新建数据列名:
ID,
Category,
Company,
Description,
Update frequency #,
Time since last update [hours],
Measurement (hours/min)
New_Sample_data:
ACC-1-Nike, ACC, Nike, shoes made of wood, 12, 3, hours
我一直在尝试创建一个包含三列的新表:
Column 1: Name of all the columns (to be compared)
Column 2: Original_Data_value
Column 3: New_Data_Value
我想要实现的输出:
----------------------------------------------------
| Column Names | Org_Value | New_Value |
----------------------------------------------------
| ID | ACC-1-NIKE | ACC-1-NIKE |
----------------------------------------------------
| Category | ACC | ACC |
----------------------------------------------------
| Description | shoes with acc | shoes made of wood|
----------------------------------------------------
| Update frequency| 12 | 12 |
----------------------------------------------------
我希望新表显示原始数据和新数据的值不匹配的地方。我该如何做到这一点?目的是比较原始价值和新价值,以便能够识别从原始价值到新价值的变化。
我一直在尝试使用"Union all"one_answers"Cross join",但任何建议都非常受欢迎。
非常感谢您抽出时间。
查找所有已更改的原始元组:
SELECT [columns you want to compare] FROM Original_data
--FROM New_data - if you want the new data tuples
EXCEPT
(
SELECT [columns you want to compare] FROM Original_data
INTERSECT
SELECT [columns you want to compare] FROM New_data
)
现在,您可以连接这些表并逐列比较以获得"新数据"。。。
问候