我试图找出具有MS Sql嵌套查询的正确语法,我希望从另一列中获取值,然后将结果转换为绝对值,然后插入到视图中。我该怎么做呢?
CREATE VIEW -- select * from
[Product_Revenue]
AS
SELECT Name,[REV_Accounted_Debit]-[REV_Accounted_Credit] as [diff]
select abs[diff] as Amount from SalesListing
FROM [SalesListing]
答案 0 :(得分:1)
没有必要对此进行递归。
CREATE VIEW -- select * from
Product_Revenue
AS
SELECT Name,
REV_Accounted_Debit]-[REV_Accounted_Credit as diff,
abs(REV_Accounted_Debit-REV_Accounted_Credit) as Amount
FROM SalesListing