我正在编写一个查询来定义一个视图Sybase Database
。考虑以下示例
SELECT a, (b+c+d-e) AS derived_1, (b+c+d-e)+2 AS derived_2, (b+c+d-e)+4 as derived_3
FROM TABLENAME
您可以看到我使用一些逻辑(b+c+de)计算了一个值,应用了更多逻辑并为不同的派生列返回值。有什么办法可以让我只写一次 (b+c+de) 吗?
就像是
SELECT a, (b+c+d-e) AS derived_1, derived_1+2 AS derived_2, derived_1+4 as derived_3
FROM TABLENAME