select count(HostManId) as jifen from Costumecomm where HostManId=125 and Times between '2006-12-22 12:01:17' and '2006-10-02 12:01:17'这个SQL语句有没有问题,呀,为什么不能够查找数据

解决方案 »

  1.   

    lz  times是什么数据类型的?
      

  2.   

    select count(HostManId) as jifen from Costumecomm where HostManId=125 and cast(Times as datetime) between '2006-12-22 12:01:17' and '2006-10-02 12:01:17'
    贴点数据出来吧~
      

  3.   


    把And前后的数据换一下。Between的用法是值要大于等于And前面的,小于等于And后面的。
      

  4.   

    Times
    2006-10-02 12:01:17
    2006-10-05 12:01:38
    2006-10-08 18:10:45
    2006-10-09 16:56:38
    2006-10-09 17:00:00
    2006-10-10 09:01:36
    2006-10-10 13:59:16
    2006-10-10 16:41:00
    2006-10-11 13:02:40
    2006-10-11 15:55:57
    2006-10-11 16:00:31
    2006-10-11 22:32:24
    2006-10-12 13:43:40
    2006-10-12 14:47:28
    2006-10-12 16:21:15
    2006-10-13 11:27:50
    2006-10-13 20:56:52
    2006-10-14 08:55:31
    2006-10-14 14:49:18
    2006-10-14 14:53:25
    2006-10-14 15:38:24
    2006-10-14 21:16:46
    2006-10-16 11:09:58
    2006-10-16 11:14:37
    2006-10-16 17:38:40
    2006-10-17 13:58:29
    2006-10-17 21:10:54
    2006-10-17 21:23:12
    2006-10-17 21:27:58
    2006-10-17 21:33:09
    2006-10-18 13:34:50
    2006-10-18 16:37:00
    2006-10-18 17:43:15
    2006-10-18 17:45:38
    2006-10-19 09:32:46
    2006-10-19 09:34:39
    2006-10-19 11:42:57
    2006-10-19 11:45:57
    2006-10-19 11:51:02
    2006-10-19 11:52:15
    2006-10-19 11:54:22
    2006-10-19 11:58:22
    2006-10-19 16:07:42
    2006-10-19 16:09:13
    2006-10-19 16:54:29
    2006-10-19 16:55:49
    2006-10-19 17:20:33
    2006-10-19 17:23:22
    2006-10-19 21:54:14
    2006-10-20 08:35:09
    2006-10-20 09:00:57
    2006-10-20 15:29:43
    2006-10-20 17:18:39
    2006-10-20 17:33:31
    2006-10-20 18:08:51
    2006-10-20 18:17:31
    2006-10-21 08:19:31
    2006-10-21 09:08
    2006-10-21 09:57
    2006-10-21 14:09
    2006-10-23 09:13
    2006-10-23 11:37
    2006-10-23 18:40
    2006-10-24 10:37
    2006-10-24 12:06
    2006-10-24 12:07
    2006-10-24 12:10
    2006-10-24 17:31
    2006-10-24 17:35
    2006-10-24 17:58
    2006-10-25 09:41
    2006-10-25 11:05
    2006-10-25 11:07
    2006-10-25 13:14
    2006-10-25 14:52
    2006-10-25 14:53
    2006-10-25 14:59
    2006-10-25 16:03
    2006-10-25 16:04
    2006-10-26 09:15
    2006-10-26 09:32
    2006-10-26 11:45
    2006-10-26 11:46
    2006-10-26 12:44
    2006-10-27 09:33
    2006-10-27 11:05
    2006-10-27 11:48
    2006-10-27 11:49
    2006-10-27 13:32
    2006-10-27 13:36
    2006-10-27 15:46
    2006-10-27 16:52
    2006-10-27 21:03
    2006-10-28 11:33
    2006-10-28 21:22
    2006-10-28 23:10
    2006-10-30 09:14
    2006-10-30 10:16
    2006-10-30 22:54
    2006-10-31 14:53
    2006-11-01 09:05
    2006-11-01 09:36
    2006-11-01 10:44
    2006-11-02 08:51
    2006-11-02 09:33
    2006-11-02 09:36
    2006-11-03 09:35
    2006-11-03 10:03
    2006-11-05 23:53
    2006-11-05 23:54
    2006-11-06 09:25
    2006-11-08 15:04
    2006-11-08 21:40
    2006-11-09 09:47
    2006-11-11 21:34
    2006-11-12 19:36
    2006-11-12 19:38
    2006-11-12 20:00
    2006-11-12 20:51
    2006-11-12 20:53
    2006-11-13 00:12
    2006-11-13 20:48
    2006-11-16 20:05
    2006-11-17 21:31
    2006-11-17 21:47
    2006-11-21 09:43
    2006-11-22 09:42
    2006-11-22 10:39
    2006-11-22 10:58
    2006-11-22 11:01
    2006-11-24 22:19
    2006-11-26 20:23
    2006-11-26 20:41
    2006-11-26 21:15
    2006-11-27 18:20
    2006-11-27 22:04
    2006-11-27 22:49
    2006-11-28 11:39
    2006-11-28 15:36
    2006-11-28 17:44
    2006-11-29 21:38
    2006-11-29 21:46
    2006-11-30 22:51
    2006-12-01 15:46
    2006-12-01 15:47
    2006-12-03 14:23
    2006-12-03 14:39
    2006-12-03 14:45
    2006-12-03 14:48
    2006-12-03 14:55
    2006-12-03 14:57
    2006-12-03 15:42
    2006-12-03 18:14
    2006-12-03 20:45
    2006-12-03 21:04
    2006-12-04 10:42
    2006-12-04 10:57
    2006-12-04 10:58
    2006-12-04 22:20
    2006-12-05 20:23
    2006-12-06 16:10
    2006-12-07 08:45
    2006-12-07 14:26
    2006-12-07 22:23
    2006-12-07 22:30
    2006-12-08 11:04
    2006-12-08 17:14
    2006-12-13 17:04
    2006-12-16 13:58
    2006-12-16 14:00
    2006-12-16 15:50
    2006-12-18 15:53
    2006-12-18 16:11
    2006-12-19 15:10
    2006-12-20 11:21
    2006-12-20 18:49
    2006-12-20 20:41
    2006-12-24 13:52
    2006-12-24 14:12
    2006-12-24 22:03
    2006-12-25 15:55
    2006-12-26 10:00
      

  5.   

    后面的一段要先转成字符型后面加:00再转成DATETIME
      

  6.   

    select count(HostManId) as jifen from Costumecomm where HostManId=125 and cast(Times as datetime) between cast('2006-12-22 12:01:17' as datetime) and cast('2006-10-02 12:01:17' as datetime)