做个查询,字段1值除3,如果=1,就用字段2值-20,如果=2,字段2 值-30,将差值大于0的数据选出来
SELECT col1, col2,
CASE
WHEN col1 / 3 = 1 THEN col2 - 20
WHEN col1 / 3 = 2 THEN col2 - 30
END AS difference
FROM price
WHERE (
CASE
WHEN col1 / 3 = 1 THEN col2 - 20
WHEN col1 / 3 = 2 THEN col2 - 30
END > 0)