If statement 以公式为条件的if子句

If statement 以公式为条件的if子句,if-statement,conditional-statements,divide,If Statement,Conditional Statements,Divide,在给定的查询中,我想给出条件: if mha(material handling area) has name HB1(mha='HB1') then CAST(SUM(minloc) - SUM(noinloc) AS DECIMAL(6,0)) AS '_FREe places' divide with number 2. 怎么可能写出来呢?我尝试使用IF子句,但得到失败消息 SELECT mha, locstat, loctype, SUM(noinloc) '_Kolli', SUM

在给定的查询中,我想给出条件:

if mha(material handling area) has name HB1(mha='HB1') then 
CAST(SUM(minloc) - SUM(noinloc) AS DECIMAL(6,0)) AS '_FREe places' divide with number 2.
怎么可能写出来呢?我尝试使用IF子句,但得到失败消息

SELECT mha, locstat, loctype, SUM(noinloc) '_Kolli', SUM(minloc) '_Plasser',
CAST(SUM(minloc) - SUM(noinloc) AS DECIMAL(6,0)) AS '_Free places''
FROM L30T1
GROUP BY mha, locstat, loctype
ORDER BY mha, locstat, loctype

您使用什么语言?嘿,这是在SMSS:D结果中:选择mha、locstat、loctype、SUM(noinloc)‘uKolli’、IIF(mha=‘HB1’、SUM(minloc/2)、SUM(minloc))’、‘uPlasser’、IIF(mha=‘HB1’、SUM(minloc/2)-SUM(noinloc)、SUM(minloc)-SUM(noinloc))作为来自L30T1组的‘uTomme Plasser’、locstat、locstat、loctype、loctype、locstat、loctype、loctype、loctype