我有一个 SQL 请求:
SELECT table1.nr1 / NULLIF(table2.nr2, 0) as percentage
我想用关系代数来写这个。
是否可以用关系代数来表示算术除法?
最佳答案
根据this course of the University of Rochester关系代数可以定义为
a formal system for manipulating relations
- Operands of this algebra are relations.
Operations of this algebra include the usual set operations (since relations are sets of tuples), and special operations defined for relations
selection
projection
join
这是一个关于关系的代数,没有数字的表示。如果您想对数字使用算术,则必须使用扩展形式主义,例如 Safe Database Queries with Arithmetic Relations .
关于select - 关系代数中的算术除法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33843276/