27,579
社区成员
发帖
与我相关
我的任务
分享
distinct
select
*
from
(select px=row_number()over(partition by Name ,Price ,Time ,Describ order by getdate()),* from tb)t
where
px=1
select distinct Name, Price, Time, Describ from P
--方法一:
select * from tb a where id=(select max(id) from tb where Name=a.Name and price=a.price and Time=a.time and Describ=a.Describ)
--方法二
select * fromt b a where not exists(select 1 from tb where Name=a.Name and price=a.price and Time=a.time and Describ=a.Describ and id>a.id)
select
*
from
p t
where
id=(select max(id) from p where Name=t.Name and Price=t.Price and [Time]=t.[Time] and Describ=t.Describ)
select * from P t
where not exists(select 1 from P where Name=t.Name and Price=t.Price
and [Time]=t.[Time] and Describ=t.Describ and id<t.Describ )