22,209
社区成员
发帖
与我相关
我的任务
分享
--测试数据
if not object_id(N'Tempdb..#T') is null
drop table #T
Go
Create table #T([starttime] time,[score] int,[id] int,[endtime] time)
Insert #T
select '11:12:02',5345,60,'11:34:54' union all
select '11:12:02',5345,61,'11:34:54' union all
select '11:12:02',5345,77,'11:34:54' union all
select '11:10:02',320,77,'11:33:47' union all
select '11:10:02',320,26,'11:33:47' union all
select '11:12:02',535,10,'11:34:54'
Go
--测试数据结束
SELECT a.*
FROM #T a
JOIN ( SELECT DISTINCT
starttime ,
score ,
endtime
FROM #T
WHERE id = 77
) b ON b.endtime = a.endtime
AND b.score = a.score
AND b.starttime = a.starttime