select caccount
from table1
where ctelephone between '3814' and '3826'

解决方案 »

  1.   

    用户数,刚才看错了。select count(*)
    from table1
    where ctelephone between '3814' and '3826'
      

  2.   

    BETWEEN可以用于计算字符型数据的吗?
      

  3.   

    select caccount
    from table1
    where substring(ctelephone,1,4) between '3814' and '3826'
      

  4.   

    select count(*)
    from table1
    where ctelephone between '3814' and '3826'与select count(*)
    from table1
    where ctelephone like '3814%' or ctelephone like '3815%'........... or ctelephone like '3825%'计算出来的结果不一样喔!为什么呢??
      

  5.   

    TO 无为:
    加了SUBSTRING之后,运算速度就明显慢很多了。如果不用这些转换函数还有什么其它写法吗?
      

  6.   

    再TO 无为:
    而且你这句的运行结果与中海那句是一样的。
    还是与这句,最原始的写法运算出来的结果不一样。到底哪个对?select count(*)
    from table1
    where ctelephone like '3814%' or ctelephone like '3815%'........... or ctelephone like '3825%'
      

  7.   

    select count(*) from table where cast(ctelephone as int)>=3814000 and cast(ctelephone as int)<=3825999
      

  8.   

    select count(*)
    from table1
    where convert(int,substring(ctelephone,1,4)) >=  '3814' and convert(int,substring(ctelephone,1,4)) <= '3826'