Re: referring to calculated column in sub select

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: referring to calculated column in sub select
Дата
Msg-id 20090519092729.GQ22221@samason.me.uk
обсуждение исходный текст
Ответ на Re: referring to calculated column in sub select  (Scara Maccai <m_lists@yahoo.it>)
Список pgsql-general
On Tue, May 19, 2009 at 12:04:28AM -0700, Scara Maccai wrote:
> Using Mysql the query works, so I expected it to be somehow "standard"
> (I know, Mysql sometimes allows much more than the standard...)

No, as far as I know the standard explicitly says that the MySQL
behaviour is incorrect.

> Does this has something to do with Support LATERAL subqueries" in the
> to do list?

No, a lateral sub-query would be something like the following:

  SELECT f.a, b.b
  FROM foo a, getrows(a.a) b(b);

I.e. in order to execute the "getrows" function you need to have values
out of "foo" first.  You can do this in some specific instances at the
moment in PG, but not in general.

> It's a very shame it's not supported...

another rewrite of your query would be to have a sub-select:

  SELECT acoltest,
    (SELECT max(t) FROM mytab WHERE anothercol=acoltest) as col2
  FROM (SELECT somet, acol+100 AS acoltest FROM mytab2)
  GROUP BY somet;

Hope that helps!

--
  Sam  http://samason.me.uk/

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

Предыдущее
От: Sebastien FLAESCH
Дата:
Сообщение: Re: INTERVAL SECOND limited to 59 seconds?
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: INTERVAL SECOND limited to 59 seconds?