SELECT count(t.c) FROM 
(SELECT Count(*) as c,V_PAGEVIEW.cid FROM V_PAGEVIEW GROUP BY V_PAGEVIEW.cid) 
as t INNER JOIN V_PAGEVIEW ON t.cid = V_PAGEVIEW.cid where 
entertime>'2007-1-19' and entertime<'2007-1-20' and t.c>1 and WGID='[email protected]
大家帮忙看一下这条SQL有什么问题吗,一执行就后数据库就会一直在"正在执行查询"的状态下

解决方案 »

  1.   

    SELECT count(*) c FROM
    V_PAGEVIEW 
    having c>=2
    and entertime>'2007-1-19' and entertime<'2007-1-20' and WGID='[email protected]'
      

  2.   

    --改一下這個條件, 字段名是一樣的entertime>'2007-1-19' and entertime<'2007-1-20'
      

  3.   

    entertime>'2007-1-19' and entertime<'2007-1-20'--條件始終為TRUE, 估計進入了死循環
      

  4.   

    这条SQL是要取今日老客户的访问量
    所以不能写成这样SELECT count(*) c FROM
    V_PAGEVIEW 
    having c>=2
    and entertime>'2007-1-19' and entertime<'2007-1-20' and WGID='[email protected]'
      

  5.   

    有什么解决办法吗?当不使用 WGID='[email protected]'这个条件时,完全可以正确执行
      

  6.   

    改成entertime>'2007-1-19 00:00:00' and entertime<'2007-1-20 00:00:00' 试试
      

  7.   

    跟时间没有关系,只有当加上这个and WGID='[email protected]'检索条件时才会出现数据库一直在查询中。。
      

  8.   

    把and WGID='[email protected]'放到时间查询的前面
    并且将'[email protected]'中的.进行转义处理