我有以下 sql 查询
SELECT
i.catalogid, i.itemname,
CASE WHEN o.oshippeddate is not null
AND o.oshippeddate between @Date1 AND @Date2
THEN ISNULL(i.F2,0)
ELSE 0 END +
CASE WHEN o.oshippeddate2 is not null
AND o.oshippeddate2 between @Date1 AND @Date2
THEN ISNULL(i.F3,0)
ELSE 0 END +
CASE WHEN o.oshippeddate3 is not null
AND o.oshippeddate3 between @Date1 AND @Date2
THEN ISNULL(i.F4,0)
ELSE 0 END AS amount,
amount*i.ekprice EK,
amount * (i.unitprice
- ((i.unitprice/((o.otax/100)+1))
- o.odiscount-o.oshipcost-o.coupondiscount) VK
FROM orders o
INNER JOIN oitems i
ON i.orderid = o.orderid
如果您查看我要选择的最后 2 列,它们是从列数量生成的,它本身是使用 select case 语句生成的新列,我是 sql 新手,我想知道如何让这样的东西工作,所以基本上它说invalid column name amount