计算表上的实例(Count instances on a table)
如果我有一个包含重复实例的表,如果我没有计数功能,我怎么算?
我只有选择,项目,联合,差异,产品,交叉,njoin。 我正在使用WinRDBI 。
表看起来像这样:
孩子
ID| AME| A | 'alice' A | 'jon' A | 'alex' B | 'joe' B | 'mary' C | 'amy'亲
ID| AME| A | 'Smith' B | 'Johnson' C | 'Meyer'我想知道父母有两个孩子的情况。
If I have a table with duplicate instances how can I count if I don't have a count function?
All I have is select, project, union, difference, product, intersect, njoin. I am using WinRDBI.
Table looks like this:
Children
ID| AME| A | 'alice' A | 'jon' A | 'alex' B | 'joe' B | 'mary' C | 'amy'Parent
ID| AME| A | 'Smith' B | 'Johnson' C | 'Meyer'I want to know how what parent has two children.
最满意答案
当n> 0时,使用差值运算符和(n*n)-n = n仅对于n = 2为真。
对于每个父母,通过重命名儿童的第二个副本[称之为“C1”],创建他们的孩子的交叉产品[称之为“C”]。 我们称之为“CxC1”
如果(((从CxC1选择C的属性) - C)= C)那么父母正好有2个孩子[1]
[1]假设参照完整性使父母不能有零孩子。
Use the difference operator and the fact that (n*n)-n = n is true only for n = 2 when n > 0.
For each parent, create a cross product of their Children [call this "C"] with itself by renaming second copy of Children [call this "C1"]. Let's call this "CxC1"
If (((select attributes of C from CxC1) - C) = C) then the parent has exactly 2 children [1]
[1] Assuming referential integrity such that a parent cannot have zero children.
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
推荐阅读
留言与评论(共有 17 条评论) |
本站网友 穴穴 | 24分钟前 发表 |
如果我没有计数功能 | |
本站网友 燕塘牛奶官网 | 14分钟前 发表 |
我怎么算? 我只有选择 | |
本站网友 哇嘎嘎 | 5分钟前 发表 |
交叉 | |
本站网友 长春科技学院 | 29分钟前 发表 |
create a cross product of their Children [call this "C"] with itself by renaming second copy of Children [call this "C1"]. Let's call this "CxC1" If (((select attributes of C from CxC1) - C) = C) then the parent has exactly 2 children [1] [1] Assuming referential integrity such that a parent cannot have zero children. | |
本站网友 哪些水果养胃 | 15分钟前 发表 |
通过重命名儿童的第二个副本[称之为“C1”] | |
本站网友 深圳春运 | 28分钟前 发表 |
我怎么算? 我只有选择 | |
本站网友 梦见蛇好吗 | 23分钟前 发表 |
交叉 | |
本站网友 手麻 | 20分钟前 发表 |
差异 | |
本站网友 民间治咳嗽的52个偏方 | 10分钟前 发表 |
product | |
本站网友 富力又一城户型图 | 16分钟前 发表 |
差异 | |
本站网友 毛鸡蛋是什么 | 19分钟前 发表 |
使用差值运算符和(n*n)-n = n仅对于n = 2为真 | |
本站网友 深圳房子出售 | 16分钟前 发表 |
产品 | |
本站网友 熏香 | 25分钟前 发表 |
njoin | |
本站网友 自动顶贴 | 14分钟前 发表 |
union | |
本站网友 韩国整形美容 | 1分钟前 发表 |
通过重命名儿童的第二个副本[称之为“C1”] | |
本站网友 卡拉蜂 | 16分钟前 发表 |
product |