问题:
table
id name
1 2013070003
2 2013070123
3 2013070120
4 2013070050
1.此字段位數相同,即10位,
2.此字段前綴相同,即201307
我要得到的是
id name
1 3
2 123
3 120
4 50
回答1:
SELECT 0+RIGHT(name,4)WHERE LEFT(name,6)='201307' AND LENGTH(name)=10
回答2:
select id,right(name,4)+0 from tb
回答3:
select id,trim(LEADING,'0',left(name,4)) from tabale