日期:2014-05-17 浏览次数:20539 次
select top 1
Id,User_Id,[Count],Working_Count,Complete_Count
from Task where [User_Id] <> 168
and [Count]-(Complete_Count+Working_Count)>0
and Id not in (select Task_Id from Task_Log where User_Id=168 and [Type]=1 and Status <> 0)
and Id not in (891,929,934,600,716,692,885,910,652,659,696,699)
SELECT Task_Id as ID
into #tempID
FROM Task_Log
WHERE User_Id=168 and [Type]=1 and [Status] <> 0
INSERT #tempID
SELECT 891 UNION ALL
SELECT 929 UNION ALL
SELECT 934 UNION ALL
SELECT 600 UNION ALL
SELECT 716 UNION ALL
SELECT 692 UNION ALL
SELECT 885 UNION ALL
SELECT 910 UNION ALL
SELECT 652 UNION ALL
SELECT 659 UNION ALL
SELECT 696 UNION ALL
SELECT 699
SELECT TOP 1 a.Id,User_Id,[Count],Working_Count,Complete_Count
FROM Task a left join #tempID b
on a.Id=b.ID
WHERE [User_Id] <> 168 and [Count]-(Complete_Count+Working_Count)>0 and b.ID is null