如何查找表中的上一行和下一行 [英] How to look for the previous and next row in a table

查看:97
本文介绍了如何查找表中的上一行和下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在使用SQL访问系统表并使用Crystal来运行报告。

有''在Crystal中用于之前的函数一个用于下一个带来前一个或下一个记录。


有没有办法在SQL中执行此操作?

我已经在网上查看但只发现令人困惑答案...


谢谢!

Hi all,

I''m using SQL to access system tables and using Crystal on top of that to run reports.
There''s a function in Crystal for "previous" and one for "next" which bring the previous or next record.

Is there a way of doing this in SQL?
I''ve looked on the web but only found confusing answers...

Thanks !

推荐答案

我会想象''上一个''和''下一个' '在Crystal中是结果集中的下一个记录,而不是表中的下一个记录。

要模拟这个,你需要一些前端代码,因为SQL没有表中记录顺序的概念
I would imagine that the ''Previous'' and ''Next'' in Crystal are the next records from a resultset, not the next records in the table.
To simulate this you will need some front end code as SQL has no concept of the order of records in a table


SQL表有一个ID列,虽然每个文件的ID号不是按顺序排列,但每个新记录只增加1,无论记录链接到哪个文件

...这有意义吗?


也许一个公式会查看每个文件的最大ID号?
the SQL table has an ID column, although the ID number isn''t in sequence for each file, it just increases by 1 for each new record regardless of which file the record is linked to
...does that make sense?

Maybe a formula that would look at the greatest of the ID numbers for each file?


我不清楚你想要实现什么。

如果你想做分页,你需要保留在内存中的当前页面。

然后你做一个类似
It is not clear to me what you are trying to achieve.
If you want to do paging you need to keep in memory the current page.
Then you do a query something like
展开 | 选择 | Wrap | 行号


这篇关于如何查找表中的上一行和下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆