日期:2014-05-18  浏览次数:20419 次

引用其它表的计算列的表达式?
SQL code
SELECT     dbo.xs.xuehao As 学号, dbo.xs.xingming As 姓名, dbo.xm.xm As 项目, dbo.xm.adfee As 项目预交费, 5000 AS 实交费
FROM         dbo.xs RIGHT OUTER JOIN
                      dbo.xm ON dbo.xs.zhuanye = dbo.xm.zhuanye AND dbo.xs.nianji = dbo.xm.nianji

想把5000替换为引用实际收费表fee(feeid,xuehao,xm,fee)的一个表达式计算出该生该项目的实际交费。

------解决方案--------------------
SQL code
SELECT     dbo.xs.xuehao As 学号, dbo.xs.xingming As 姓名, dbo.xm.xm As 项目, dbo.xm.adfee As 项目预交费, dbo.fee.fee AS 实交费
FROM         dbo.xs RIGHT OUTER JOIN
                      dbo.xm ON dbo.xs.zhuanye = dbo.xm.zhuanye AND dbo.xs.nianji = dbo.xm.nianji
                LEFT OUTER JOIN
                      dbo.fee ON  dbo.xm.xm =dbo.fee.xm AND dbo.xs.xuehao = dbo.fee.xuehao