2016-08-03 101 views

回答

0

麻煩參閱表結構試試:(UPDATE)

select name, t.date_cnt 
from yourtable 
join (select count(distinct `date`) as date_cnt from yourtable) t 
group by name 
having count(distinct `date`) = date_cnt 

Demo Here

對於過去6天數:

select name, t.date_cnt 
from yourtable 
join (
    select count(distinct `date`) as date_cnt 
    from yourtable 
    where str_to_date(`date`, '%d-%m-%y') >= date_add(now(), interval -6 day) 
) t 
where str_to_date(`date`, '%d-%m-%y') >= date_add(now(), interval -6 day) 
group by name 
having count(distinct `date`) = date_cnt 

Last 6 days demo

+0

無法識別的關鍵字十字架 –

+0

@ShahidAhmed更新了我的答案,請再次檢查。 – Blank

+0

對於同一張表,我需要相同的輸出,但只有當前日期的最後6天。 –

相關問題