当前位置: 代码迷 >> Sql Server >> SQL语句怎么查询一段数字的前两位数是多少
  详细解决方案

SQL语句怎么查询一段数字的前两位数是多少

热度:19   发布时间:2016-04-24 10:35:13.0
SQL语句如何查询一段数字的前两位数是多少
表Table

codes    names
01          1
0101      1_1
0102      1_2
02          2
0201      2_1
0202      2_2
03          3
0301      3_1
0302      3_2

我查询出两位数
select * from table where len(codes)>0 and len(codes)<3 

codes   names
01           1
02            2
03           3
然后想查出前两位数为01的项
就是想查询结果为 
codes   names
0101     1_1
0101     1_2
求大神指教啊!!!!!!
------解决方案--------------------
select * from #test where LEFT(codes,2)='01'
  相关解决方案