如何计算 2 个表之间的不同数量?
how to count quantity of different between 2 tables?
我需要计算 2 table 秒之间的差异(来自 2 个不同日期的相同 table)以查看发生了什么变化。
例如table1:
table 2:
我想得到这个 table:
我试试这个代码:
select a.of_key , case when a.color != b.color then count (a.color) ELSE 0 END AS color,
case when a.side != b.side then count (a.side) else 0 end as side
from 130720 A right JOIN 100720 B
ON a.of_key = b.of_key and a.num = b.bum
group by a.of_key
它不工作
请帮忙
谢谢!
将您的汇总放在 case 语句之外:
select a.of_key , SUM(case when a.color != b.color then 1 ELSE 0 END) AS color,
SUM(case when a.side != b.side then 1 else 0 end) as side
from 130720 A right JOIN 100720 B
ON a.of_key = b.of_key and a.num = b.bum
group by a.of_key
我需要计算 2 table 秒之间的差异(来自 2 个不同日期的相同 table)以查看发生了什么变化。
例如table1:
table 2:
我想得到这个 table:
我试试这个代码:
select a.of_key , case when a.color != b.color then count (a.color) ELSE 0 END AS color,
case when a.side != b.side then count (a.side) else 0 end as side
from 130720 A right JOIN 100720 B
ON a.of_key = b.of_key and a.num = b.bum
group by a.of_key
它不工作
请帮忙
谢谢!
将您的汇总放在 case 语句之外:
select a.of_key , SUM(case when a.color != b.color then 1 ELSE 0 END) AS color,
SUM(case when a.side != b.side then 1 else 0 end) as side
from 130720 A right JOIN 100720 B
ON a.of_key = b.of_key and a.num = b.bum
group by a.of_key