在关系代数中等同于GroupBy和Having子句 [英] Equivalent of GroupBy and Having clause in Relational Algebra
本文介绍了在关系代数中等同于GroupBy和Having子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个任务,我不得不将SQL查询转换为关系代数查询。我遇到了转换组
子句。
I was doing an assignment where I had to convert SQL queries into Relational Algebra queries. I got stuck in converting the group by
clause.
任何人都可以告诉我如何group by子句以关系代数写?
Could anyone please tell me how the group by clause can be written in relational algebra?
例如:
SELECT job, sal
FROM emp
GROUP BY job
;
$ b
谢谢!
Thanks!
推荐答案
首先你的查询是错误的,你不能选择你没有分组,除非你使用聚合。我假设你想得到sal的总和。
First of all your query is wrong you cannot select something that you did not group unless you use aggregation. I assume you want to get sum of the sal.
job F sum(sal),job(emp)。
job F sum(sal), job(emp).
这篇关于在关系代数中等同于GroupBy和Having子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文