我有2个查询。当所有线程以打印完成的形式完成处理和警报时,我基本上需要从2个查询中解决。要执行此操作 - 如果当前处理查询与总放置查询输出编号匹配,则在该批次中完成所有线程。我需要创建一个PRINT Complete的存储过程。这样做的最佳方式是什么?
- 处理多少 - 首先(但未处理)
SELECT COUNT(IsProcessed) as 'Current Put through'
FROM [dbo].[threads]
- 当前已处理 - 通过Isprocessed标志1递增1到1的值逐步增加
SELECT COUNT(IsProcessed) 'Current_Processing'
FROM [dbo].[threads] as count
where IsProcessed=1
答案 0 :(得分:1)
你可以做以下的事情吗?
IF NOT EXISTS (SELECT 1 FROM dbo.Threads WHERE IsProcessed != 1)
BEGIN
PRINT 'Complete'
END
ELSE
BEGIN
PRINT 'Ongoing'
END
答案 1 :(得分:0)
select *,
case when cntAll = cntProcessed then 'Complete' else 'Ongoing' end as Status
from (
select count(case when IsProcessed = 1 then 1 else NULL end) Current_Processing,
count(1) 'Current Put through'
from [dbo].[threads])A