Skip site navigation (1) Skip section navigation (2)

Re: Union

From: felipe fernandez <ffdezrguez(at)tiscali(dot)es>
To: Postgresql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Union
Date: 2007-04-28 04:33:32
Message-ID: 4632CE9C.2000200@tiscali.es (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
Jaime Casanova escribió:
> On 4/27/07, Victor Lopez <d01m01a2000(at)gmail(dot)com> wrote:
>> > select referencia, foto1, localidad
>> > from (
>> > SELECT REFERENCIA,FOTO1,LOCALIDAD, fecha, hora
>> > FROM tabla1
>> > WHERE FOTO1 != ''
>> >               AND ESTADO = 3
>> >               AND CATEGORIA IN (SELECT CODIGO FROM CATEGORIAS WHERE 
>> GRUPO=6)
>> >              AND DESTACADO = TRUE
>> > UNION ALL
>> > SELECT REFERENCIA,FOTO1,LOCALIDAD, fecha, hora
>> > FROM tabla1
>> > WHERE FOTO1 != ''
>> >               AND ESTADO = 3
>> >               AND CATEGORIA IN (SELECT CODIGO FROM CATEGORIAS WHERE 
>> GRUPO=6)
>> >               AND  DESTACADO = FALSE
>> > ) foo
>> > ORDER BY FECHA DESC, HORA DESC LIMIT 1;
>> >
>>
>> Por interpretar ... yo interpreto que quiere que los destacados salgan
>>  antes de los no destacados.
>>
>> Pregunta :
>>
>> ORDER BY DESTACADO ASC, ....
>> o
>> ORDER BY DESTACADO DESC, ...
>>
>
> no. porque lo esta ordenando explicitamente por fecha y hora, no por 
> destacado
>> ORDER BY FECHA DESC, HORA DESC LIMIT 1;
>
Para que primero salgan los destacados debo incluirlos en el order, 
efectivamente.

In response to

  • Re: Union at 2007-04-28 04:30:33 from Jaime Casanova

Responses

  • Re: Union at 2007-04-28 16:43:03 from Victor Lopez

pgsql-es-ayuda by date

Next:From: Jaime CasanovaDate: 2007-04-28 04:39:54
Subject: Re: vacuum full
Previous:From: Jaime CasanovaDate: 2007-04-28 04:30:33
Subject: Re: Union

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group