donglinxia1541 2013-09-20 17:33 采纳率: 0%
浏览 59

SELECT COUNT(*)列中2个数字之间的位置

I am trying to count how many records I have in my column 'routeorder' that are between 2 numbers. The column has information like:

RouteOrder
ACC-001-01
ACC-001-01
ACC-001-01
ACC-001-01
ACC-015-18
ACC-015-18
ACC-015-18
ACC-015-18
ACC-015-19
ACC-015-19
ACC-015-19
ACC-015-19
ACC-015-19
ACC-016-01
ACC-016-01
ACC-016-01
ACC-017-19
ACC-017-19
ACC-017-19
ACC-017-19
ACC-017-19
ACC-017-19
ACC-017-19

I need to get how many records between 'ACC-001' and 'ACC-016' Is there a way to do it ? This is what I have so far:

SELECT COUNT(*) as areatotals FROM Customers WHERE SUBSTRING(routeorder,LENGTH(routeorder),-3) like 'ACC'

Thanks for the help.

  • 写回答

3条回答 默认 最新

  • duanmiyang6201 2013-09-20 17:38
    关注

    Going from the example given on the official documentation, you should be able to that:

    SELECT COUNT(*) as areatotals FROM Customers WHERE routeorder BETWEEN 'ACC-001' AND 'ACC-016';

    This should trigger a string conversion as described here.

    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗