有一组数据
10
20
30
1020
1030
2010
2020
2050
301010开头的为一组数据,1020为其子节点,我用order byrd只能得到上面的结果,如何得到10开头的ID都在一起的结果?

解决方案 »

  1.   

    select  a.*,(Convert(varchar(10),p.CompIndex)+'.'+Convert(varchar(10),J.Indexed)+'.'+Convert(varchar(10),a.ActivityNumber)+' '+a.ActivityName)as activityIdenx  from P_ActivityInfo a left join P_CommpontSeed J on a.ItemForm=J.ComponentSeedID left join P_Component P on J.ComponentID=p.ComponentID   where a.IsDecompound='0' and a.ItemID = '" + sItemID + "' and IsDecompound=0 order by p.CompIndex,J.Indexed,a.ActivityNumber参考下
      

  2.   

    SELECT *  from  [tablename] order by  CAST([id] AS varchar(2)) 
      

  3.   


    SELECT *  from  [tablename] order by  left(id,2) 
      

  4.   

    谢谢楼上几位
    left还能这么用,记住了