Home » SQL & PL/SQL » SQL & PL/SQL » Union and sort the data based on date range (11G)
Union and sort the data based on date range [message #677020] Wed, 07 August 2019 19:28 Go to next message
laknar
Messages: 30
Registered: February 2009
Member
There are two tables which need to be combined based on date range and last transaction date. Consecutive records should be within the date range.

Table1:-
Acc_no, acc_name,type,open_date, last_modified_dt
1001,corporate,S,1990-10-10, 2018-12-01

Table2:-
Acc_no, address,type,from_date, to_date, last_modified_dt
1001,blvd, C, 1990-10-10, 2000-12-01, 2018-12-12
1001, Fredericksburg, C, 1990-10-10, 2012-05-13, 2019-01-31
1001, Fredericksburg, C, 2012-10-10, 2018-05-13, 2019-03-31

Output:-
1001, Fredericksburg, C, 2019-03-31
1001,blvd, C, 2018-12-12
1001, Fredericksburg, C, 2019-01-31
1001,corporate,S,2018-12-01
Re: Union and sort the data based on date range [message #677021 is a reply to message #677020] Wed, 07 August 2019 19:36 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read
Re: Union and sort the data based on date range [message #677027 is a reply to message #677020] Thu, 08 August 2019 00:41 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.

Also always post your Oracle version, with 4 decimals, as solution depends on it.

Previous Topic: Comprimir una imagen utilizando AS_ZIP
Next Topic: REQEXP_SUBTR debug
Goto Forum:
  


Current Time: Thu Mar 28 14:49:39 CDT 2024