如何实现?
4 个解决方案
#1
select * from t
where source in (select source from t where id = 77)
where source in (select source from t where id = 77)
#2
--测试数据
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
#3
select * from A where A.sour in(
(select A.sour from Awhere A.UserId= 77))
(select A.sour from Awhere A.UserId= 77))
#4
select * from A where A.socre in(
(select A.socre from A where A.Id= 77)) SQL中直接用这个可以查询出来数据,看他们写的好复杂的样子
(select A.socre from A where A.Id= 77)) SQL中直接用这个可以查询出来数据,看他们写的好复杂的样子
#1
select * from t
where source in (select source from t where id = 77)
where source in (select source from t where id = 77)
#2
--测试数据
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
#3
select * from A where A.sour in(
(select A.sour from Awhere A.UserId= 77))
(select A.sour from Awhere A.UserId= 77))
#4
select * from A where A.socre in(
(select A.socre from A where A.Id= 77)) SQL中直接用这个可以查询出来数据,看他们写的好复杂的样子
(select A.socre from A where A.Id= 77)) SQL中直接用这个可以查询出来数据,看他们写的好复杂的样子