34,593
社区成员
发帖
与我相关
我的任务
分享
DECLARE @Table table(Dtime datetime,[name] nvarchar(200),state bit )
insert into @Table select '2008-07-16 10:00:00.000','应用1',1
insert into @Table select '2008-07-16 10:00:00.000','应用2',0
insert into @Table select '2008-07-16 10:00:00.000','应用2',1
--select * from @table
select Dtime,[name],min(case state when 0 then 0 else 1 end) as state from @table group by dtime,[name]
SELECT DTIME,[NAME],MIN(STATE)
FROM [TABLE]
GROUP BY DTIME,[NAME]