我有一个查询如下。我想在行中返回每个文件名(alter.pdf
,modify.pdf
)的大小写值。
但是我只获得alter.pdf
的案例值。
SELECT CASE WHEN COUNT(P.[packageid]) > 0 THEN 1 ELSE 0 END AS [VALUE]
FROM [Table_1] AS P
INNER JOIN
[Table_2] AS F on F.FileID = P.FileID
WHERE F.FileName IN('alter.pdf','modify.pdf')
答案 0 :(得分:1)
我认为你正在寻找这样的东西:
SELECT F.[FileName]
, sum(CASE WHEN F.FileName = 'alter.pdf' THEN 1
WHEN F.FileName = 'modify.pdf' THEN 1
ELSE 0
END AS) [VALUE]
FROM [Table_1] AS P
INNER JOIN [Table_2] AS F on F.FileID = P.FileID
WHERE F.FileName IN('alter.pdf','modify.pdf')
group by F.[FileName]