关系代数 SQL
Relational Algebra SQL
大家好我想知道我是否可以得到一些帮助解决问题
Postimi(状态)(Post_ID:整数,user_ID:整数,测试:字符串,data:date,时间:整数)
我需要学习与 Postimi 相关的关系代数
问题是
列出昨天发布了两个或更多状态而今天没有发布任何状态的用户?
如果有人可以帮助我。
提前致谢
select yd.user_ID
from status yd -- yd for yesterday
where yd.date = current_date() - interval 1 day
and not exists (
select *
from status td -- td for today
where td.user_ID = yd.user_ID
and td.date = current_date()
)
group by yd.user_ID
having count(*) >= 2
或
select user_ID
from status
where date >= current_date() - interval 1 day
and date <= current_date()
group by user_ID
having count(*) >= 2
and max(date) < current_date()
大家好我想知道我是否可以得到一些帮助解决问题
Postimi(状态)(Post_ID:整数,user_ID:整数,测试:字符串,data:date,时间:整数)
我需要学习与 Postimi 相关的关系代数
问题是
列出昨天发布了两个或更多状态而今天没有发布任何状态的用户?
如果有人可以帮助我。 提前致谢
select yd.user_ID
from status yd -- yd for yesterday
where yd.date = current_date() - interval 1 day
and not exists (
select *
from status td -- td for today
where td.user_ID = yd.user_ID
and td.date = current_date()
)
group by yd.user_ID
having count(*) >= 2
或
select user_ID
from status
where date >= current_date() - interval 1 day
and date <= current_date()
group by user_ID
having count(*) >= 2
and max(date) < current_date()