select * from a b where not exists(select 1 from a c where b.oprator_time<c.operator_time) and user='admin' and status=1;
select * from a where operator_time=( select min(operator_time) from a where user='admin' and status='1') and user='admin' and status='1';
--1楼的思路不错,学习了 --但需要改一下 select * from a b where not exists(select 1 from a c where b.oprator_time >c.operator_time where c.user=b.user and c.status=b.status) and user='admin' and status=1;
能解释下 not exists(select 1 from a c where b.oprator_time >c.operator_time 这里为什么这么写吗?
嗯,我考虑不周,sorry,忘了加条件了
select * from a where status='1' AND user='admin' and operator_time =(select min(operator_time ) as operator_time from a where status='1' AND user='admin' )
select * from (select * from a where status='1' AND user='admin' order by operator_time) where rownum=1;
select * from a where (id,operator_time) in ( select id,min(operator_time) from a where user='admin' and status='1' group by (id) );
select min(operator_time) from a where user='admin' and status='1')
and user='admin' and status='1';
--但需要改一下
select * from a b where not exists(select 1 from a c where b.oprator_time >c.operator_time where c.user=b.user and c.status=b.status)
and user='admin' and status=1;
a
where (id,operator_time) in
(
select id,min(operator_time)
from a
where user='admin' and status='1'
group by (id)
);