【发布时间】:2021-03-19 11:10:30
【问题描述】:
我正在运行这个查询
select * from
(select name, count(distinct id) as ids, date
from table1
group by name, date ) as tt
full outer join
(select st_name as name,count(distinct id) as ids, date
from table2
group by st_name, date) as ts
on tt.name= ts.name
and tt.ids = ts.ids
它运行成功,但我想问一下是否有其他更有效的方法来运行这个查询。
【问题讨论】:
-
查询试图做什么?该代码非常奇怪,因为它可能会从不同日期获取 id 的数量并将它们显示为相等 - 这似乎没有用。
-
我试图在这2个表匹配后找到table1或table2中不存在的行
-
@DrGenious 。 . .您可能希望在
on子句中使用date。