本帖最后由 sea267 于 2012-11-12 09:29:36 编辑

解决方案 »

  1.   

    select *from (select name,work_date ,count(*) as counts
    from work_log  
    group by name,work_date
    with ROLLUP) b
    where name is not null and work_date is null and  counts is not null
      

  2.   

    这样也行:
    select name,work_date ,count(*) as counts
    from work_log
    group by name,work_date
    union 
    select null,null,count(*) as counts
    from work_log
      

  3.   

    后边加having条件也行HAVING (`name` IS NOT NULL AND work_date IS NOT NULL) OR (`name` IS NULL AND work_date IS NULL)
      

  4.   

    select name,work_date ,count(*) as counts
    from work_log  
    group by name,work_date
    having isnull(name) xor isnull(work_date)=0
    with ROLLUP;
      

  5.   


    我从来没用过 xor 这个关系符!学习学习,哈哈。
      

  6.   


    额 俺也没整过 XOR 第一次看到这个词, 上面的语句改成 
    select name,work_date ,count(*) as counts 
    from work_log 
    group by name,work_date 
    with ROLLUP 
    having isnull(name) xor isnull(work_date)=0 
     可以正常运行