由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - SQL check likeness between two large tables (转载)
相关主题
sort two same tables SQL but different results (转载)感覺多倫多今年就業行情不錯
error of executing SQL query of string concatenation[合集] 如果只是programmer也是经常加班的吗
add column name in exporting table netezza aginity sql (转载)[合集] 想问个职业规划的问题~
SQL copy a table into a new table and add a new column (转载)[合集] Front-Offce, Mid-Office and Back-Office区别在那?
SQL add some columns into a table from another table (转载Help: learning SQL
Hedge Fund manager Seth Klarman's video on investing金融工程程序大收集
有MD来第一轮面试的么?求Hedge Fund公司软件开发面试题
【zz】一则市场评论 It's Bear's world请教求职面试题:如何写一个SQL query求N行N列表中对角线的和
相关话题的讨论汇总
话题: sql话题: table2话题: table1话题: rows话题: tables
进入Quant版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: SQL check likeness between two large tables
发信站: BBS 未名空间站 (Tue May 6 15:38:29 2014, 美东)
I need to check the likeness between two data tables on SQL. I am working on
Aginity Workbench for Netezza on Win 7.
The tables are very large. One of them has 100 million rows and 4 columns;
another one has 1500 million rows and 3 columns.
Example, table1
ID1 ID2 ID3 Value
xxxx xxxxxx xxxxxxxx xxx.xxxxxx // here x is 0-9 int
table2:
ID1 ID2 Value
xxxx xxxxxx xxx.xxxxxx
the ID1 and ID2 may be duplicated but Values are not duplicated in the same
table.
I need to check whether table1 is a subset of table2 and find the rows that
are avaialble in table1 but not in table2 and vice versa.
I am new to SQL. How to design the efficient SQL queries ? I need to do the
same tasks frequently, so en efficient query may be more helpful.
I use this method :
SELECT * FROM table1 a
WHERE NOT EXISTS (
SELECT table2.ID1
FROM table2 b
WHERE b.ID1 = a.ID1
AND b.ID2 = a.ID2)
But, the results are 0 rows. I also checked that there are no duplicated
rows in the two tables. Why table2 is much larger than table1 ?
Are there other ways to find their differences ?
Thanks
1 (共1页)
进入Quant版参与讨论
相关主题
请教求职面试题:如何写一个SQL query求N行N列表中对角线的和SQL add some columns into a table from another table (转载
所有热心大虾们: 请帮我策划一下我接下来该学什么技能吧.Hedge Fund manager Seth Klarman's video on investing
Quant Analyst Position有MD来第一轮面试的么?
有没有书讲 VBA与SQL和MATLAB之间通讯的?谢了【zz】一则市场评论 It's Bear's world
sort two same tables SQL but different results (转载)感覺多倫多今年就業行情不錯
error of executing SQL query of string concatenation[合集] 如果只是programmer也是经常加班的吗
add column name in exporting table netezza aginity sql (转载)[合集] 想问个职业规划的问题~
SQL copy a table into a new table and add a new column (转载)[合集] Front-Offce, Mid-Office and Back-Office区别在那?
相关话题的讨论汇总
话题: sql话题: table2话题: table1话题: rows话题: tables