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);

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

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...

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 * from (SELECT 表.*,rank() OVER(PARTITION BY A_ID ORDER BY A_DATE DESC) CT FROM 表)temp order by temp.ct,temp.A_DATE desc 是不是就可以了?试一下,没有实际的表。

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

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...

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

with p as (select t1.id,t1.content,t1.process_name,t1.pid, t1.process_num from (select t.*, row_number() over(partition by t.pid order by t.process_num desc ) ord tb_process t ) t1 where ord =1)select c.*,p.* from tb_case c,p w...

select * from A, (select max(id) id_m, 某个字段 from A group by 某个字段) B where A.id = B.id_m

网站地图

All rights reserved Powered by www.qnmk.net

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