• J Livingston SQL (7/26/2016)


    is it as simple as this ....??

    SELECT * FROM (

    SELECT * FROM #City

    UNION ALL

    SELECT * FROM #Subcity) x

    ORDER BY Years DESC, Citycode, subcitycode

    edit....just rechecked my results.....aint what you have asked for....hmmm.

    J Livingston was close. The confusing thing is that the parent city isn't displayed for child cities, but it's still sorted by the parent city.

    SELECT Price, CityCode, SubCityCode, Years FROM (

    SELECT Price, CityCode, SubCityCode, Years, CityCode AS CitySort FROM #City

    UNION ALL

    SELECT Price, SubCityCode, SubCityCode, Years, CityCode FROM #Subcity

    ) x

    ORDER BY Years DESC, CitySort, subcitycode

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA