SQL 查询语句求助
作者&投稿:庞股 (若有异议请与网页底部的电邮联系)
select a.号码,a.业务,max(办理时间) as 办理时间
from 表1 as a,
(select 号码,业务 from 表1 group by 号码,业务 having count(*)>1) as b
where a.号码=b.号码
and a.业务=b.业务
group by a.号码,a.业务
假设表名 table1
列名分别问 c1 c2 c3
select c1,c2,max(c3)
from table1
where 1=1
group by c1,c2
having count(c1)>1 and count(c2)>1
select 办理数据
from 表1
where 号码='A' and 业务=01 ;
是这样吗
QL2008_CODE:
select 号码, 业务, MAX(办理时间) from T1 group by 号码, 业务
select 号码 业务 办理时间 from (select rownum,号码,业务,办理时间 from 表1 order by 办理时间 desc) r where 号码 = A and 业务 = 01 and r.rownum = 1;
应该是这样.
select * from table a
where exits(select * from table b
where a.number = b.number
and a.yewu = b.yewu
and a.time > b.time
and a.rowid > b.rowid)
~