由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - help with SAS sql (转载)
相关主题
MySQL 的一个问题求教SORTING 中文 IN ORACLE
How to split a column into several rows?sort
有趣的Join问题,源于SQL和SAS比较。Help needed: How to sort the dates in MS Access
Re: How to find a duplicate record in Acsql面试题1
how to find duplicates in mysql用SSIS EXPORT 到 EXCEL 2010 有2000个COLUMN,可能吗
A weird error问一个query
请教三个Key的property,A question
list duplicators in one table如何实现host structure嵌套?
相关话题的讨论汇总
话题: sas话题: score话题: sql话题: duplicate话题: null
进入Database版参与讨论
1 (共1页)
s****y
发帖数: 76
1
【 以下文字转载自 Statistics 讨论区 】
发信人: smiley (smiley), 信区: Statistics
标 题: help with SAS sql
发信站: BBS 未名空间站 (Fri Nov 29 22:27:30 2013, 美东)
Hi friends,
I have a question on how to eliminate duplicate rows only when there is a
null value for duplicate ids:
id score
1 55
1 .
2 .
3 74
3 80
4 67
5 40
How do I get rid of second row only (id=1 and score=.)?
Thanks much!!!
c*****a
发帖数: 177
2
不知道下面这样是否最优,权当抛砖引玉。另外用SAS里的SORT PROC应该更方便。
select * from tmp_t
where not (score is null and id in
(select t2.id
from tmp_t t2
inner join (select id from tmp_t
where score is not null) t1
on t1.id=t2.id
where t2.score is null))
s****y
发帖数: 76
3
谢谢解答, proc sort只能去掉第一个ob,given duplicate id吧?
c*****a
发帖数: 177
4
试下下面这个方法:
proc sort data=id_score;
by id descending score;
run;
data data_out(drop=keep);
set id_score;
by id descending score;
retain keep;
if first.id then
if score=. then keep=1;
else keep=0;
if ^first.id & keep=0 & score=. then delete;
run;
1 (共1页)
进入Database版参与讨论
相关主题
如何实现host structure嵌套?how to find duplicates in mysql
about:SQL的执行效率A weird error
急!如何编译一个pro*c/c++文件请教三个Key的property,
Why can't I find the proC compiler?list duplicators in one table
MySQL 的一个问题求教SORTING 中文 IN ORACLE
How to split a column into several rows?sort
有趣的Join问题,源于SQL和SAS比较。Help needed: How to sort the dates in MS Access
Re: How to find a duplicate record in Acsql面试题1
相关话题的讨论汇总
话题: sas话题: score话题: sql话题: duplicate话题: null