日期:2014-05-18 浏览次数:20450 次
SELECT c.ThreeCantonNumber as areano,c.ThreeCantonName,(a.FirstCantonName+b.SecondCantonName+c.ThreeCantonName) as AreaName from( SELECT a.FirstCantonNumber, b.SecondCantonNumber, c.ThreeCantonNumber, a.FirstCantonName, b.SecondCantonName, c.ThreeCantonName FROM dbo.T_FirstCanton a LEFT OUTER JOIN dbo.T_SecondCanton b ON a.FirstCantonNumber = b.FirstCantonNumber LEFT OUTER JOIN dbo.T_ThreeCanton c ON b.SecondCantonNumber = c.SecondCantonNumber ) t--加个别名
------解决方案--------------------
SELECT c.ThreeCantonNumber as areano,c.ThreeCantonName,(a.FirstCantonName+b.SecondCantonName+c.ThreeCantonName) as AreaName from( SELECT a.FirstCantonNumber, b.SecondCantonNumber, c.ThreeCantonNumber, a.FirstCantonName, b.SecondCantonName, c.ThreeCantonName FROM dbo.T_FirstCanton a LEFT OUTER JOIN dbo.T_SecondCanton b ON a.FirstCantonNumber = b.FirstCantonNumber LEFT OUTER JOIN dbo.T_ThreeCanton c ON b.SecondCantonNumber = c.SecondCantonNumber ) as a --别名
------解决方案--------------------
SELECT ThreeCantonNumber as areano,ThreeCantonName,(FirstCantonName+SecondCantonName+ThreeCantonName) as AreaName from ( SELECT a.FirstCantonNumber, b.SecondCantonNumber, c.ThreeCantonNumber, a.FirstCantonName, b.SecondCantonName, c.ThreeCantonName FROM dbo.T_FirstCanton a LEFT OUTER JOIN dbo.T_SecondCanton b ON a.FirstCantonNumber = b.FirstCantonNumber LEFT OUTER JOIN dbo.T_ThreeCanton c ON b.SecondCantonNumber = c.SecondCantonNumber ) AS T
------解决方案--------------------
SELECT c.ThreeCantonNumber as areano,c.ThreeCantonName,(a.FirstCantonName+b.SecondCantonName+c.ThreeCantonName) as AreaName from( SELECT a.FirstCantonNumber, b.SecondCantonNumber, c.ThreeCantonNumber, a.FirstCantonName, b.SecondCantonName, c.ThreeCantonName FROM dbo.T_FirstCanton a LEFT OUTER JOIN dbo.T_SecondCanton b ON a.FirstCantonNumber = b.FirstCantonNumber LEFT OUTER JOIN dbo.T_ThreeCanton c ON b.SecondCantonNumber = c.SecondCantonNumber )tt
------解决方案--------------------
直接
SELECT c.ThreeCantonNumber as areano,c.ThreeCantonName,(a.FirstCantonName+b.SecondCantonName+c.ThreeCantonName) as AreaName FROM dbo.T_FirstCanton a LEFT OUTER JOIN dbo.T_SecondCanton b ON a.FirstCantonNumber = b.FirstCantonNumber LEFT OUTER JOIN dbo.T_ThreeCanton c ON b.SecondCantonNumber = c.SecondCantonNumber
------解决方案--------------------
子查询必须别名
SELECT ThreeCantonNumber as areano,ThreeCantonName,(FirstCantonNameA+SecondCantonNameB+ThreeCantonNameC) as AreaName from ( SELECT a.FirstCantonNumber, b.SecondCantonNumber, c.ThreeCantonNumber, a.FirstCantonName AS FirstCantonNameA , b.SecondCantonName AS FirstCantonNameB , c.ThreeCantonName AS FirstCant