First SQL statement
Select CompanyName GSMC,ZB Zhibiao from Left Join T_companycode on T_GSNDZB.GSBH=T_companycode.companyid
Query Result:
A second SQL statement
SELECT min(CompanyName) GSMC,cast(round(sum(T_xstj.hsje)/10000,2) asNumeric -,2)) Ndje fromT_xstj Left JoinT_companycode onT_companycode.companyid=T_XSTJ.GSBHwhere DateDiff( YearSjgetdate())=0 Group byGsbh
Query Result:
Statements that are merged into a single table:
Select IsNull(A.GSMC,B.GSMC) GSMC,IsNull(A.zhibiao,0) Zhibiao,IsNull(B.ndje,0) Ndje from ( --results of the second table query-- SelectCompanyName GSMC,ZB Zhibiao fromT_gsndzb Left JoinT_companycode onT_gsndzb.gsbh=T_companycode.companyid) A Full JOIN ( --results of the second table query-- SELECT min(CompanyName) GSMC,cast(round(sum(T_xstj.hsje)/10000,2) asNumeric -,2)) Ndje fromT_xstj Left JoinT_companycode onT_companycode.companyid=T_XSTJ.GSBHwhere DateDiff( YearSjgetdate())=0 Group byGSBH) b onA.gsmc=B.gsmc
Results:
SQL Server merges two tables queried by two SQL query statements into a single table