我有以下内容将几个查询合并为一个,但是我还想添加一个额外的列,对于重复项添加“是”或“否”,但是,我的IIF语句只返回“否”。是否可以提出解决此方法的方法?
SELECT ztUnion.[PID (NOD)], ztUnion.Tasking, IIf(Count([PID (NOD)])>1,"Yes","No") AS [Multi Value]
FROM (SELECT qselAG.[PID (NOD)], qselAG.Tasking
FROM qselAG
UNION
SELECT qselWORKING.[PID (NOD)], qselWORKING.Tasking
FROM qselWORKING
UNION
SELECT qselNN.[PID (NOD)], qselNN.Tasking
FROM qselNN
UNION SELECT qselSHAM.[PID (NOD)], qselSHAM.Tasking
FROM qselSHAM
) AS ztUnion
GROUP BY ztUnion.[PID (NOD)], ztUnion.Tasking;