我有一个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.