我不知道如何编写SQL代码来获取表1中显示的行数为+/- 1的rownames数。例如,因为rownumber在彼此之内,所以我会将'Exclusive'和'Popular Episodes'计算在内。但是我不会将'Popular Movies'计算在内,因为差距大于1.通常情况下,我会交换表格,但我只知道如何使用INTERSECT进行精确匹配。sql count其中2个表中的记录几乎匹配
Table 1
+------------------+-----------+
| rowname | rownumber |
+------------------+-----------+
| Exclusive | 1 |
| Popular Movies | 3 |
| New Seasons | 7 |
| Popular Episodes | 8 |
+------------------+-----------+
Table 2
+------------------+-----------+
| rowname | rownumber |
+------------------+-----------+
| Exclusive | 2 |
| Popular Episodes | 7 |
| Popular Movies | 8 |
+------------------+-----------+
在此先感谢您的帮助!
如果New Seasons在表1中为1,而在表2中为NULL(不存在),那么可以计算一下吗? –