1

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

Richard Povinelli
  • 1,419
  • 1
  • 14
  • 28
nthed
  • 11
  • 1

1 Answers1

0

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.

Community
  • 1
  • 1
dcp
  • 54,410
  • 22
  • 144
  • 164
  • To complete the picture: The recursive common table expression is supported by Firebird, PostgreSQL, H2 Database, DB2 and Teradata. It is also supported in the newest Oracle release (11gR2) in addition to the connect by queries –  Mar 29 '11 at 18:29