Ver Mensaje Individual
  #6 (permalink)  
Antiguo 06/02/2009, 03:45
seyko
 
Fecha de Ingreso: febrero-2007
Mensajes: 1.292
Antigüedad: 17 años, 2 meses
Puntos: 13
Respuesta: intercarlar dos select por fecha.

Código:
pruebas=# \d candidatos
                            Table "public.candidatos"
    Column    |  Type   |                        Modifiers
--------------+---------+---------------------------------------------------------
 id           | integer | not null default nextval('candidatos_id_seq'::regclass)
 f_alta       | date    |
 f_entrevista | date    |
 entrevistado | boolean |
Indexes:
    "candidatos_pkey" PRIMARY KEY, btree (id)

pruebas=# insert into candidatos (f_alta, entrevistado )select now()::date + n* interval '1 day', false from generate_series(1,10) as n;
INSERT 0 10
pruebas=# insert into candidatos (f_entrevista, entrevistado )select now()::date + n* interval '1 day', true from generate_series(1,10) as n;
INSERT 0 10

select * from candidatos order by(COALESCE (f_alta, f_entrevista));
 id |   f_alta   | f_entrevista | entrevistado
----+------------+--------------+--------------
  1 | 2009-02-07 |              | f
 11 |            | 2009-02-07   | t
  2 | 2009-02-08 |              | f
 12 |            | 2009-02-08   | t
  3 | 2009-02-09 |              | f
 13 |            | 2009-02-09   | t
  4 | 2009-02-10 |              | f
 14 |            | 2009-02-10   | t
 15 |            | 2009-02-11   | t
  5 | 2009-02-11 |              | f
 16 |            | 2009-02-12   | t
  6 | 2009-02-12 |              | f
 17 |            | 2009-02-13   | t
  7 | 2009-02-13 |              | f
  8 | 2009-02-14 |              | f
 18 |            | 2009-02-14   | t
  9 | 2009-02-15 |              | f
 19 |            | 2009-02-15   | t
 10 | 2009-02-16 |              | f
 20 |            | 2009-02-16   | t
(20 rows)
Un ejemplo vale más que mil explicaciones!

Salu2