Oracle 跨两个表计数
我有两个具有相同列的表。一个表包含导入的数据,另一个表包含特定于我的应用程序的数据:
IMPORT_TABLE MY_TABLE
COL1 COL2 COL1 COL2
"A" "1" "A" "2"
"B" "1" "B" "1"
我需要做的是编写一个查询,该查询将告诉我,对于 COL1 中的给定值,我在各个表的 COL2 中具有不同的值。因此,当我运行查询时,我将返回 COL1 的值“A”。这告诉我需要将“A”“1”插入到MY_TABLE中。
我怎样才能完成查询?我知道如何在单个表上进行分组,但不知道如何跨表进行分组。
I have two tables that have identical columns. One table houses imported data, the other table houses data specific to my application:
IMPORT_TABLE MY_TABLE
COL1 COL2 COL1 COL2
"A" "1" "A" "2"
"B" "1" "B" "1"
What I need to do is write a single query that will tell me, for a given value in COL1, I have differing values in COL2 across the tables. So, when I run the query I woud get back the value "A" for COL1. This tells me that I need to insert "A" "1" into MY_TABLE.
How can I accomplish the query? I know how to do a Group By on a single table but not across tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想获取
IMPORT_TABLE
中不存在于MY_TABLE
中的行,如果 col1 是唯一的,您也可以这样做
If you just want to get the rows in
IMPORT_TABLE
that don't exist inMY_TABLE
If col1 is unique, you could also do