目前有个字段如下:希望写一个排序第二个‘-’左边的按照字符串排序,右边的按照数字排序

档案号
B10-1-40
B10-1-5
B10-1-6
B10-1-7

实现sql格式如下:

select * from tablename order by
left(档案号,charindex('-',档案号,charindex('-',档案号)+1)-1),
convert(int,substring(档案号,charindex('-',档案号,charindex('-',档案号)+1)+1,10))

 

来源:http://zhidao.baidu.com/link?url=Dc0vTh3nHH7TPqaseGs4YG_IumYaf6xH4xNIjuP3JTS_KU8_usvZMGxcQnh5kJJR68McOb6qWop7jjH9IuvI7q

相关文章:

  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-01-03
  • 2021-12-15
猜你喜欢
  • 2021-11-26
  • 2021-11-16
  • 2022-12-23
  • 2018-04-11
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案