我从表Sales
获得此值销售
对于案例或其他函数,我想做一个操作并根据旧的日期分离结果,我不需要将列添加到表中,只需在查询结果中添加列。 / p>
查询结果
由于
答案 0 :(得分:0)
根据您所写的内容,我会尝试以下内容:
SELECT
DaysOld,
Amount, --assuming you meant 'amount' when you said 'mount'
CASE
WHEN DaysOld > 0 AND DaysOld <= 15 THEN Amount
ELSE 0
END AS Amount1to15,
CASE
WHEN DaysOld > 15 AND DaysOld <= 31 THEN Amount
ELSE 0
END AS Amount16to31 --added to include months w/ 31 days
FROM Sales