select * from (select ...)as t1 join (select...) as t2 on t1.a = t2.a
select ISNULL(sum(a.Payable_AMT),0), dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT from B_OutInter a WHERE a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001') group by a.OutInter_CDSELECT a.OutInter_CD, U_Cname=(select u_cname from sys_user where userid='13'), U_MobileNo=(select U_MobileNo from sys_user where userid='13'), c.Outsour_NM,a.Ctct_NM,a.Tel_No, e.G_Cname,b.U_CName FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and a.groupid=e.groupid and a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001')
select * from (第一个查询的查询语句)a left join (第二个查询的查询语句) b on a.a=b.a
[code=SQL]select * from (select a.OutInter_CD ,ISNULL(sum(a.Payable_AMT),0) as Payable_AMT, dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT from B_OutInter a WHERE a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001') group by a.OutInter_CD )a left join ( SELECT a.OutInter_CD, U_Cname=(select u_cname from sys_user where userid='13'), U_MobileNo=(select U_MobileNo from sys_user where userid='13'), c.Outsour_NM,a.Ctct_NM,a.Tel_No, e.G_Cname,b.U_CName FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and a.groupid=e.groupid and a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001')) b on a.OutInter_CD=b.OutInter_CD[/code]
from a inner join b on a.a=b.a
ISNULL(sum(a.Payable_AMT),0),
dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT
from
B_OutInter a
WHERE a.ActionFlag = '1'
AND a.OutInter_CD in ('WC0910160001') group by a.OutInter_CDSELECT
a.OutInter_CD,
U_Cname=(select u_cname from sys_user where userid='13'),
U_MobileNo=(select U_MobileNo from sys_user where userid='13'),
c.Outsour_NM,a.Ctct_NM,a.Tel_No,
e.G_Cname,b.U_CName
FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c
WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and
a.groupid=e.groupid and a.ActionFlag = '1'
AND a.OutInter_CD in ('WC0910160001')
dbo.LowerToUpper(ISNULL(sum(a.Payable_AMT),0)) AS UPPayable_AMT
from B_OutInter a
WHERE a.ActionFlag = '1' AND a.OutInter_CD in ('WC0910160001') group by a.OutInter_CD
)a left join (
SELECT a.OutInter_CD, U_Cname=(select u_cname from sys_user where userid='13'),
U_MobileNo=(select U_MobileNo from sys_user where userid='13'),
c.Outsour_NM,a.Ctct_NM,a.Tel_No,
e.G_Cname,b.U_CName
FROM B_OutInter a,sys_group e,sys_user b,M_Outsourcing c
WHERE a.creator=b.userid and a.OutInterGrp_CD=c.Outsour_CD and
a.groupid=e.groupid and a.ActionFlag = '1'
AND a.OutInter_CD in ('WC0910160001')) b on a.OutInter_CD=b.OutInter_CD[/code]
http://topic.csdn.net/u/20091013/22/a3b22548-b1ec-48de-b4f7-cf81ddeafe62.html