我是 SQL 新手,所以请考虑这个菜鸟问题。此外,承认我无法在 Google 中搜索正确的关键字而且我的时间不多了,所以我决定在这里问它。
代码:
select
*,
price * quantity as [Total price],
case
when [Total price]>100 and [Total price]<= 200 then '2%'
when [Total price]>200 and [Total price]<= 300 then '3%'
when [Total price]>300 and [Total price]<= 400 then '4%'
else '0%'
end as tax
from
grocery
如您所见,我想做的是尝试在执行 SQL 语句时创建一个临时变量,但是,这给了我错误
Error 1: could not prepare statement [1 no such column: Total price]
我怎么能这样做?