我想返回给定名称相等的所有字段,但在 psql 9.5.6 上 id 仅相差一(1)。
所以输入:
NAME | ID
______________
Harry | 12
Harry | 13
Steven | 14
Steven | 16
Goldberg | 21
输出应该是:
Harry
最佳答案
Select name from table
group by name having
max(id)- min(id)=1;
I think you asked id difference by each name as group by seeing the output. Can try the above.
关于sql - postgreSQL - 选择 id 仅相差一个的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53582421/