;with ct as
(
select row_number() over(partition by createUid order by asid) row_id
,count(*) over(partition by createUid) row_count,*
from AuctionSell
)
select *
from ct
where row_id=case when row_count>1 then 2 else 1 end
(
select row_number() over(partition by createUid order by asid) row_id
,count(*) over(partition by createUid) row_count,*
from AuctionSell
)
select *
from ct
where row_id=case when row_count>1 then 2 else 1 end
(select row_number() over (partition by createUid order by asid) num ,* from AuctionSell) ct
where num=2 or num=(select max(num) from ct b where createuid=ct.createuid ) AND NUM=1 这个句子逻辑不对,同时有and 和 or必须有括号,还有
num=(select max(num) from ct b where createuid=ct.createuid )
应该改为:
num IN(select max(num) from ct b where createuid=ct.createuid )