Max and Min of Serial Number
Dear Oracle Expert,
I need to resolve the below requirement,
There are two tables T1 and T2 and their structure are
T1
---
ID Char, SerialNo Number
T2
----
ID Char, SerialNo_From Number, SerialNO_To Number
The data for the table T1 would be as
ID SRL_NUM
---------------------
A 101
A 102
A 103
A 104
A 105
A 107
A 111
A 112
A 113
B 101
B 102
B 104
The data for the table T2 would be as
ID SRL_FROM SRL_TO
-----------------------------------------
A 101 105
A 107 107
A 111 113
B 101 103
The requirement is as follows
The records are grouped based on the column ID.
We can also mention the min as Starting number of the series and max as Ending number of the series.
First we need to get the min number of the running series for instance from the above example
forr the first series 101,102,103,104,105
the minimum is 101 and max is 105
and for the second series there is only one record so min and max would be 107
and in the final series 111,112,113 the min is 111 and max is 113.
Through PL/SQL program need to be written to identify the starting and ending number of the series and would be inserted into the
table T2 as show above.
Please help me in this regard to achieve the above solution.
Thanks in advance.