1号楼 2号楼 3号楼,.............n号楼,如何按照order by LouHao ASC排序?
------解决方案--------------------
- SQL code
IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name = 'TBC')BEGIN DROP TABLE TBCENDGOCREATE TABLE TBC( louhao VARCHAR(100))INSERT INTO TBCSELECT '1号楼' UNIONSELECT '3号楼' UNIONSELECT '2号楼' UNIONSELECT '4号楼' UNIONSELECT '6号楼' UNIONSELECT '5号楼' UNIONSELECT '8号楼' UNIONSELECT '7号楼' UNIONSELECT '9号楼' UNIONSELECT '10号楼' UNIONSELECT '12号楼' UNIONSELECT '11号楼'SELECT louhaoFROM TBCORDER BY CAST(LEFT(louhao,CHARINDEX('号',louhao) - 1) AS INT)louhao1号楼2号楼3号楼4号楼5号楼6号楼7号楼8号楼9号楼10号楼11号楼12号楼