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
这样也行: 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
后边加having条件也行HAVING (`name` IS NOT NULL AND work_date IS NOT NULL) OR (`name` IS NULL AND work_date IS NULL)
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;
我从来没用过 xor 这个关系符!学习学习,哈哈。
额 俺也没整过 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 可以正常运行
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
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
from work_log
group by name,work_date
having isnull(name) xor isnull(work_date)=0
with ROLLUP;
我从来没用过 xor 这个关系符!学习学习,哈哈。
额 俺也没整过 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
可以正常运行