Problem Description:
In processing general data records, for numeric types of fields, in Oracle sort, the null value is the default to be greater than any number of types, of course, for varchar2 type of field, the default is also the processing, but the customer requirements in the process of ordering, Null fields are required to default to the front (small-->). The general order by XXXX cannot be resolved.
Problem solving:
Programme 1:
You can use SQL with complex uses:
select * from
(select a.*,rownum as my_sys_rownum from (
select deptid,nvl(BDZNAME,' '),nvl(VOLLEVEL,'0'),ZBRL,nvl(ZBTS, '0'),
nvl(FZR,'0'),nvl(DEPTIDDES,' '),nvl(TEL,' '),nvl(RUNSTATEDES,' '),
nvl(ADDRESS,' '),BDZID from V_BDZ where rownum<2000
and ZBRL is null
) a
union
select b.*,rownum+(select count(*) from (
select deptid,nvl(BDZNAME,' '),nvl(VOLLEVEL,'0'),ZBRL,nvl(ZBTS, '0'),
nvl(FZR,'0'),nvl(DEPTIDDES,' '),nvl(TEL,' '),nvl(RUNSTATEDES,' '),
nvl(ADDRESS,' '),BDZID from V_BDZ where rownum<2000
and ZBRL is null
)) as my_sys_rownum from (
select deptid,nvl(BDZNAME,' '),nvl(VOLLEVEL,'0'),ZBRL,
nvl(ZBTS, '0'),nvl(FZR,'0'),
nvl(DEPTIDDES,' '),nvl(TEL,' '),nvl(RUNSTATEDES,' '),
nvl(ADDRESS,' '),BDZID from V_BDZ where rownum<2000
and ZBRL is not null order by ZBRL
) b
)
order by my_sys_rownum desc
Programme 2:
You can do this by using the way that you can set up comparison fields in order by in Oracle:
such as: ... order by NVL (AAA, '-1 ')