![](/img/trans.png)
[英]Mysql query - one table - find two dates within one day - of the same entity from different column + diff calculations
[英]Find a column with one value for 2 different dates
我有下表:
表格1
列如下:
date , time , user_id , channel
我希望找到在2個不同的DATES,頻道(讓我們說CNN,NBC ...)中觀看的所有用戶的列表。
表示DATE 1和DATE 2中的頻道相同,user_id也相同。
我嘗試以下所有方法:
select distinct monthname(date),max(date), min(date) count(distinct user_id)
from iptv_clean
group by monthname(date)
having min(date)!= max(date)
但這似乎效果不佳。
有任何想法嗎?
以下列出了用戶和用戶在多個日期觀看過的頻道:
select user_id, channel, count(distinct date)
from iptv_clean
group by user_id, channel
having count(distinct date) > 1;
這是你想要的嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.