大哥,这个提示是让你select子句里要包含order by子句中出现的字段select left(col1,1),right(col1,2),* from table 
order left(col1,1),right(col1,2)

解决方案 »

  1.   

    oh gosh, 看错了,不好意思哈,飘过……
      

  2.   

    沒有問題啊。Create Table [table]
    (col1 Varchar(100))
    Insert [table] Select 'A112'
    Union All Select 'B113'
    Union All Select 'D125'
    Union All Select 'C136'
    Union All Select 'A128'
    GO
    select * from [table] 
    order By left(col1,1),right(col1,2)
    GO
    Drop Table [table]
    --Result
    /*
    col1
    A112
    A128
    B113
    C136
    D125
    */
      

  3.   

    chuifengde(树上的鸟儿) ( ) 信誉:100  2007-07-19 14:38:23  得分: 0  
     
     
       order by --少了by
      
     
    ---------
    應該不是這個原因,否則錯誤提示不是這樣的。
      

  4.   

    ....剛試了下,這句也沒問題
    select * from titles
    order by left(title_id, 1), right(title_id, 1)
      

  5.   

    select *  from maps_all where (1=1) order by cast(dbo.split(col1,2) as int), cast(dbo.split(col1 ,3) as int) 这是我实际的语句。
      

  6.   

    split 函数就是分割类似 A-111-11 的字符串。
      

  7.   

    如果col1 的值是这样的
    A-12-156
    A-265-1
    A-8-25
       回复人:paoluo(一天到晚游泳的鱼) ( 四星(高级)) 信誉:100  2007-07-19 14:38:12  得分:0

    沒有問題啊。Create Table [table]
    (col1 Varchar(100))
    Insert [table] Select 'A112'
    Union All Select 'B113'
    Union All Select 'D125'
    Union All Select 'C136'
    Union All Select 'A128'
    GO
    select * from [table]
    order By left(col1,1),right(col1,2)
    GO
    Drop Table [table]
    --Result
    /*
    col1
    A112
    A128
    B113
    C136
    D125
    */
      

  8.   

    一樣沒問題的Create Table [table]
    (col1 Varchar(100))
    Insert [table] Select 'A-12-156'
    Union All Select 'A-8-25'
    Union All Select 'A-8-27'
    GO
    select * from [table]
    order By left(col1,1),right(col1,2)
    GO
    Drop Table [table]
    --Result
    /*
    col1
    A-8-25
    A-8-27
    A-12-156
    */
      

  9.   

    select * from table 
    order by left(col1,1),right(col1,2)
      

  10.   

    try
    Select 列出除了col12, col13外的所有列名
    From(select *, cast(dbo.split(col1,2) as int) As col12, cast(dbo.split(col1 ,3) as int) As col13  from maps_all) A
    Order By col12, col13
      

  11.   

    这样不行,order by 后面不能固定 回复人:paoluo(一天到晚游泳的鱼) ( 四星(高级)) 信誉:100  2007-07-19 15:04:26  得分:0

    一樣沒問題的Create Table [table]
    (col1 Varchar(100))
    Insert [table] Select 'A-12-156'
    Union All Select 'A-8-25'
    Union All Select 'A-8-27'
    GO
    select * from [table]
    order By left(col1,1),right(col1,2)
    GO
    Drop Table [table]
    --Result
    /*
    col1
    A-8-25
    A-8-27
    A-12-156
    */
      

  12.   

    order by後面的本來就是不確定的。另外,我這是舉例在普通的語句中是沒有問題的,但是order by中使用函數沒有測試,你試這個吧。Select 列出除了col12, col13外的所有列名
    From(select *, cast(dbo.split(col1,2) as int) As col12, cast(dbo.split(col1 ,3) as int) As col13  from maps_all) A
    Order By col12, col13
      

  13.   

    谢谢,这个方法可行。
     回复人:paoluo(一天到晚游泳的鱼) ( 四星(高级)) 信誉:100  2007-07-19 15:06:16  得分:0

    try
    Select 列出除了col12, col13外的所有列名
    From(select *, cast(dbo.split(col1,2) as int) As col12, cast(dbo.split(col1 ,3) as int) As col13 from maps_all) A
    Order By col12, col13