递归处理sql
我有一个表,其中包含三列 element A
、element B
和 dueDate
。如果我有以下三行:
A | B | 01/01/2010
B | C | 01/01/2011
C | D | 01/01/2012
那么我希望能够提取以下假设 ->A | d | 01/01/2012 通过使用纯 sql,或使用 java 来操作从数据库获取的数据。
谢谢
I have a table which has three columns element A
, element B
, and dueDate
. If I have the following three rows:
A | B | 01/01/2010
B | C | 01/01/2011
C | D | 01/01/2012
then I would like to be able to extract the following assumption
->A | D | 01/01/2012 either by using plain sql, or by using java to manipulate the data fetched from the database.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于您使用的数据库。例如,在
Oracle
中,您可以查看 start with / connect by 功能,这对于分层查询来说非常好。对于
SQL Server
,可以参考其他数据库也有类似的机制,您只需要研究它即可找出最佳方法。
It really depends on what database you are using. In
Oracle
, for example, you can check out the start with / connect by feature, which is really nice for hierarchical queries.For
SQL Server
, you can refer here for a similar idea.Other databases have similar mechanisms, you just need to research it to figure out the best way to do it.