当我尝试这个时,我得到一个语法错误但不确定它的方法是否可能是错误的。我正在尝试向表中添加标记以标识某些记录
Create view
as
SELECT
col1 * 0.5 / col2 as value_per_sqm,
col3 / col2 as other_value,
(col1 * 0.5 / col2) < (col3 / col2) as higher
返回;
ERROR: syntax error at or near "("
调整上面我可以看到我可以运行一个布尔值,如果我不使用方程并且前两个方程有效,则返回true。我试过了;
Create view
as
SELECT
col1 * 0.5 / col2 as value_per_sqm,
col3 / col2 as other_value,
(value_per_sqm) < other_value) as higher
但它无法查询列,因为它未创建。
感谢任何帮助
答案 0 :(得分:1)
为您提供帮助:
create view yourview
as
SELECT value_per_sqm,
other_value,
(value_per_sqm < other_value) as higher
FROM
(SELECT col1 * 0.5 / col2 as value_per_sqm,
col3 / col2 as other_value FROM yourtable) subQ;