PostgreSQL 6.1 , Linux RedHat 4.2 Kernel 2.0.30
Selecting all records and ordering ascending and descending on a field :
template1=> select * from pers order by cod;
cod|nume |salariu
- ----------------+------+-------
10 |Vasile| 45300
20 |Ion | 192300
30 |Mihai | 92300
|Fane |
(4 rows)
template1=> select * from pers order by cod desc;
cod|nume |salariu
- ----------------+------+-------
30 |Mihai | 92300
20 |Ion | 192300
10 |Vasile| 45300
|Fane |
(4 rows)
Record with nume='Fane' has NULL value in 'cod' field.
I think that ordering ascending the records on 'cod' field, records
having NULL values in 'cod' field should appear first. Should them ?
Other database information :
Database = template1
+------------------+----------------------------------+----------+
| Owner | Relation | Type |
+------------------+----------------------------------+----------+
| postgres | pers | table |
| postgres | pers_cod | index |
+------------------+----------------------------------+----------+
template1=> \d pers
Table = pers
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| cod | (bp)char
| 16 |
| nume | varchar
| 0 |
| salariu | float8
| 8 |
+----------------------------------+----------------------------------+-------+
template1=>
'pers_cod' index is unique btree indexed on field cod.
Constantin Teodorescu
FLEX Consulting
Braila, ROMANIA
E-mail: teo@flex.ro
------------------------------