Re: SQL Query

Поиск
Список
Период
Сортировка
От Scott Lamb
Тема Re: SQL Query
Дата
Msg-id 20021130080519.GA5695@calvin.slamb.org
обсуждение исходный текст
Ответ на Re: SQL Query  (Joel Burton <joel@joelburton.com>)
Ответы Re: SQL Query  (Joel Burton <joel@joelburton.com>)
Список pgsql-general
On Sat, Nov 30, 2002 at 02:45:44AM -0500, Joel Burton wrote:
> You can rewrite this w/EXISTS or with a multi-table join, and it
> should perform better:
>
> SELECT t2.*
> FROM trans AS t1,
>   trans AS t2
> WHERE
>   t1.chart_id = 10074
>   AND t1.trans_id = t2.trans_id
>   AND t2.amount >= 0
>   AND t2.transdate BETWEEN '2002-07-01' AND '2002-09-30'

Doesn't that need a "distinct" to be equivalent to the exists query? If
there are two 10074 rows with the same trans_id, I think all rows with
that trans_id would be returned twice otherwise.

--
Scott Lamb

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

Предыдущее
От: Joel Burton
Дата:
Сообщение: Re: SQL Query
Следующее
От: Hubert depesz Lubaczewski
Дата:
Сообщение: Re: strange pg_stats behaviour?