由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SQL find distinct values in large table (转载)
相关主题
compare two large tables SQL (转载)count unique values in file with 1 million rows
[SQL] just figured out how to loop through all columns in a tableHelp! proc sql;cout not null value.
keep group of values of SQL procedure in one table (转载)大牛请进,问个sas问题
SQL combine two tables into one table and add a new column (转载)SQL中啥时候用group by, 啥时候用self-join?
[Mysql] how to return NULL count in group by querySas advance chapter quiz 一问
请教proc sqlSAS Proc SQL count问题
Urgent R Question请教 macro variable 和 PROC SQL的问题
请教一个proc transpose的问题SQL run a stored procedure by fetching from a cursor row by (转载)
相关话题的讨论汇总
话题: distinct话题: table话题: large话题: values话题: select
进入Statistics版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL find distinct values in large table
发信站: BBS 未名空间站 (Wed May 21 17:20:16 2014, 美东)
I have a very large table with 1 billion rows and 12 columns, which are int,
double, varchar. I need to know the distinct values for each volume.
the table has columns :
id id_1 id_2 id_3 id_4 id_5 id_6 id_7 id_8 id_9 id_10 id_11

SELECT COUNT(distinct a.id) as num_dist_id
FROM my_large_table as a
SELECT distinct a.id
FROM my_large_table as a
It is very slow.
SELECT distinct a.id , a.id_1 , a.id_2, a.id_3, a.id_4, a.id_5, a.id_6 ...
FROM my_large_table as a
ORDER BY a.id, a.id_1, a.id_2
i need to know how many distinct values that are associated with the same
column vlue.
For example, for id = 1, how many distinct values of id_1 associated with it
.
Can I speed up the query ?
Thanks !
i**z
发帖数: 194
2
你如果用SAS 的话,用data step,可能会比 proc sql 快。

int,

【在 l******9 的大作中提到】
: 【 以下文字转载自 Database 讨论区 】
: 发信人: light009 (light009), 信区: Database
: 标 题: SQL find distinct values in large table
: 发信站: BBS 未名空间站 (Wed May 21 17:20:16 2014, 美东)
: I have a very large table with 1 billion rows and 12 columns, which are int,
: double, varchar. I need to know the distinct values for each volume.
: the table has columns :
: id id_1 id_2 id_3 id_4 id_5 id_6 id_7 id_8 id_9 id_10 id_11
:
: SELECT COUNT(distinct a.id) as num_dist_id

c******y
发帖数: 3269
3
try "group" instead of "distinct"
1 (共1页)
进入Statistics版参与讨论
相关主题
SQL run a stored procedure by fetching from a cursor row by (转载)[Mysql] how to return NULL count in group by query
请教一个简单的SQL问题请教proc sql
sas helpUrgent R Question
问一个proc sql的问题,多谢请教一个proc transpose的问题
compare two large tables SQL (转载)count unique values in file with 1 million rows
[SQL] just figured out how to loop through all columns in a tableHelp! proc sql;cout not null value.
keep group of values of SQL procedure in one table (转载)大牛请进,问个sas问题
SQL combine two tables into one table and add a new column (转载)SQL中啥时候用group by, 啥时候用self-join?
相关话题的讨论汇总
话题: distinct话题: table话题: large话题: values话题: select