我正在尝试确定当前财政年度内的所有销售额,并希望将If语句合并为计算字段。请参阅下面的代码。
SELECT RtnUserId, COUNT(*) AS Returns_, RtnDt, COUNT(RtnDt) AS DtRet,
IF
BEGIN
YEAR(RtnDt) = YEAR(GETDATE()) AND MONTH(RtnDt) >= 4
RETURN 'INDATE'
END as Financial_Period
FROM dbo.vw_AN_Admin_VendorReturns
WHERE (RtnUserId = 'BEND1') OR
(RtnUserId = 'DEENA') OR
(RtnUserId = 'RICHARDK2')
GROUP BY RtnUserId, RtnDt,
IF
BEGIN
YEAR(RtnDt) = YEAR(GETDATE()) AND MONTH(RtnDt) >= 4
RETURN'INDATE'
END