如何在数据大于祖先的地方获取RAW?
我已经根据 number 列对表进行排序:
color - string
number - integer
我需要选择那些原始表,其中 number 的比10或更大的>颜色。
因此,例如:
color number
black 1
blue 2
black 6
black 20
black 21
blue 22
blue 23
应该返回:
black 20
blue 22
请,您能建议我如何在SQLite中编写这样的查询吗?还是至少给我一些有关如何思考问题的暗示?
I have sorted table according to number column as follows:
color - string
number - integer
I need to select those raws, where the number is by 10 or more bigger than the previous one of the same color.
So for example:
color number
black 1
blue 2
black 6
black 20
black 21
blue 22
blue 23
should return:
black 20
blue 22
Please, could you suggest me how to write such a query in SQLite? Or at least give me some hints on how to think about the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
lag()
窗口函数以检查每行相同颜色的上一个数字:请参阅 demo 。
Use
LAG()
window function to check the previous number of the same color for each row:See the demo.