I don´t know where I should put some () to get the sum. Or canI do it it in some better way? :)
我不知道应该把一些()放在哪里得到总和。或者我能以更好的方式做到吗? :)
SELECT COUNT (CAST(Value as int)) FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblExtraFieldData].[Value]>'1'
AND [tblTask].[ProjectNr]= 'Offert - Bygg'
-
SELECT COUNT (CAST(Value as int)) FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblTask].[ProjectNr]= 'Offert - Bygg'
1 个解决方案
#1
0
Try this way
试试这种方式
select sum(b.a) from(
SELECT COUNT (CAST(Value as int)) as a FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblExtraFieldData].[Value]>'1'
AND [tblTask].[ProjectNr]= 'Offert - Bygg'
union all
SELECT COUNT (CAST(Value as int)) as a FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblTask].[ProjectNr]= 'Offert - Bygg') b
#1
0
Try this way
试试这种方式
select sum(b.a) from(
SELECT COUNT (CAST(Value as int)) as a FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblExtraFieldData].[Value]>'1'
AND [tblTask].[ProjectNr]= 'Offert - Bygg'
union all
SELECT COUNT (CAST(Value as int)) as a FROM [tblExtraFieldData],[tblTask]
WHERE [tblExtraFieldData].[FieldId] = '10010'
AND [tblExtraFieldData].[OwnerId]=[tblTask].[Id]
AND [tblTask].[Status]=0
AND [tblTask].[ProjectNr]= 'Offert - Bygg') b