How bout trying this?
It seems as if this data is in a hierarchical fashion.
For Example:
IT (level 1)
----Security ------ (level 2)
----------Infrastructure (level 3)
----------Software (level3)
----Applications Development--- (level 2)
---------- Oracle Applications (level 3)
---------- Internet Applications (level 3)
So you are looking for say all children records of parent record IT Department.
I would look into hierarchical queries using START WITH / CONNECT BY.
Ex:
Code:
Select a.dept, b.col 1, b.col 2
from table1 a, table2 b
start with deptname = 'Dept_you_are_starting_with'
connect by a.parent_dept_id = prior a.dept_id
where a.column = b.column
This should go down the hierarchy starting at whatever you choose. This will assume you have a column stating a departments parent.
If you dont have this column, or cant figure it out, the other suggestion I have I is to try selecting the 5 groups as substrings in your select statement. You could then order by these groups.
EX:
Code:
select col1, substr(col2, 1,15), substr(col2, 16, 30)...etc to 75
from table1
where some_criteria
order by substr(col2, 1,15), substr(col2, 16,30)...etc
Would give you all
00001 groups first (first grouping)
00002 groups second (first grouping)
______00001 groups first (2nd grouping)
______00002 groups second (2nd grouping)
So you would group by each 15 block of codes....not sure if this helps. Try both and let me know.