我之前也是想的用case when 写。可是一直报错。
能不能麻烦你写个case when 的模板。我两个价格计算公式也写好了。就是不知道怎么匹配[/quote]
表名 t1
价格类型 a
价格 pri
数量 shul
天数 ts
select case
when a = 'a2' then
t.shul * t.pri * (round(t.ts / 30) + 1)
when a = 'a1' then
t.shul * t.pri * t.ts
end as 价格,
t.*
from t1 t;
给你参考。