www.qnmk.net > orAClE查询数据去重,如表:iD,nAmE,phonE,查询结果...

orAClE查询数据去重,如表:iD,nAmE,phonE,查询结果...

select id,name,phone from tables where rowid in (select max(rowid) from tables group by phone);

SELECT distinct "PAT_MASTER_INDEX"."PATIENT_ID", "PAT_MASTER_INDEX"."NAME", "INP_PAYMENTS_MONEY"."PAYMENT_AMOUNT", "INP_PAYMENTS_MONEY"."MONEY_TYPE", "INP_SETTLE_MASTER"."CHARGES", "INP_SETTLE_MASTER"."RCPT_NO", "INP_SETTLE_MAS...

给你举个例子: 比如a表有这样几条数据 id name 1 5 2 4 3 5 4 3 那么你要查询名字不同的 语句应该是 select distinc(a.name) from a 那么查询到的结果应该是 name 5 4 3 但是实际情况并不仅仅是这么简单 比如我想查询name 不重复的所有数据 你...

CREATE TABLE #test ( ID int, name varchar(10), age int);go-- 用于测试 楼主的原始数据.INSERT INTO #testSELECT 1, 'tom', 22 UNION ALLSELECT 2, 'tom', 23 UNION ALLSELECT 3, 'tom', 24 UNION ALLSELECT 4, 'lily', 22 UNION ALLSELECT 5...

原语句: select name from stu 第一种: select name 姓名 from stu; 第二种:select name as 姓名 from stu;

你可以 group by name 取最大或最小的goods_sn

1。用rowid方法 据据oracle带的rowid属性,进行判断,是否存在重复,语句如下: 查数据: select * from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 and a.name2=b.name2......) 删数据: delete from table...

select rownum,a.* from select (name, max(results) from table_a group by name order by name) a;

问题是你其它字段不重复,同一个name,其实有多条数据,你按什么逻辑取数据,那些不同的字段怎么筛眩 如果随便取一条的话, select * from table where name='' where rownum=1;就返回一条

select * from table1 where (需要去重的字段) in (select 需要去重的字段 from table1 group by 需要去重的字段 having count(*) > 1) and id in (select min(rowid) from table1 group by 需要去重的字段 having count(*)>1)

网站地图

All rights reserved Powered by www.qnmk.net

copyright ©right 2010-2021。
www.qnmk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com