Re: Advice on re-writing a SELECT query.

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: Advice on re-writing a SELECT query.
Дата
Msg-id B6F6FD62F2624C4C9916AC0175D56D880CDF6154@jenmbs01.ad.intershop.net
обсуждение исходный текст
Ответ на Advice on re-writing a SELECT query.  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-sql
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I have a query like this:<br /> ><br
/>>SELECT<br /> >lpt_titulo AS tmt_titulo,<br /> >tmd_nombre AS tmt_nombre,<br /> >tmd_album AS
tmt_album<br/> >SUM(lpt_puntos) AS tmt_puntos,<br /> >lpt_fuente AS tmt_fuente<br /> >FROM listas_pre_titulos,
temp_lista_titulos<br/> >WHERE <br /> >listas_pre_titulos.lpt_tipo = 3 AND<br />
>listas_pre_titulos.lpt_titulo<> temp_lista_titulos.tmt_titulo AND<br /> >listas_pre_titulos.tmd_album
<>temp_lista_titulos.tmt_album AND<br /> >listas_pre_titulos.lpt_fuente <>
temp_lista_titulos.tmt_fuente<br/> >GROUP BY <br /> >lpt_fuente, lpt_titulo, tmd_album<br /> >ORDER BY
tmt_puntosASC<br /> ><br /> >Is it valid to re-write the FROM and WHERE statements as follows?<br /> ><br />
>FROMlistas_pre_titulos<br /> >INNER JOIN temp_lista_titulos ON <br /> >(listas_pre_titulos.lpt_titulo,
listas_pre_titulos.tmd_album,listas_pre_titulos.lpt_fuente) <br /> >NOT IN <br />
>(temp_lista_titulos.tmt_titulo,temp_lista_titulos.tmt_album, temp_lista_titulos.tmt_fuente)<br /> >WHERE
listas_pre_titulos.lpt_tipo= 3<br /><br /> hello, <br /> your second syntax is not valid sql, but you can achieve it as
inthis example:<br /><br /> create temp table a(a int,b int,c int,d int);<br /> create temp table b(a int,b int,c int,d
int);<br/><br /> select * from a join b ON ((a.a,a.b,a.c)<>(b.a,b.b,b.c))<br /><br /> but beware if null values
areinvolved( 1<>NULL => NULL).<br /> In this case you can use :<br /> select * from a join b ON ((a.a,a.b,a.c)
ISDISTINCT FROM (b.a,b.b,b.c))<br /><br /> regards,<br /><br /> Marc Mamin<br /><br /></div> 

В списке pgsql-sql по дате отправления:

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: Advice on re-writing a SELECT query.
Следующее
От: Guillaume Lelarge
Дата:
Сообщение: Re: DELETE...RETURNING problem with libpq