Thanx Tom. On Πεμ 14 ÎÎ±Ï 2013 12:17:46 Tom Lane wrote: > Achilleas Mantzios <ach...@matrix.gatewaynet.com> writes: > > dynacom=# SELECT DISTINCT ON (qry.setid) qry.setid, qry.arragg[1:2] FROM > > (select distinct sst.setid,(array_agg(vsl.name) OVER (PARTITION BY > > sst.setid ORDER BY character_length(vsl.name))) as arragg > > FROM sissets sst, vessels vsl WHERE vsl.id=sst.vslid ORDER BY > > sst.setid) as qry > > WHERE array_length(qry.arragg,1)>1 AND qry.setid IN (SELECT setid > > from sis_oper_cons) ORDER BY qry.setid,array_length(qry.arragg,1); > > [ works ] > > > however, there is not column setid in sis_oper_cons, > > If not, that's a perfectly legal outer reference to qry.setid. > > Probably not one of SQL's better design features, since it confuses > people regularly; but it's required by spec to work like that. > > regards, tom lane > > > - Achilleas Mantzios IT DEV IT DEPT Dynacom Tankers Mgmt
-- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql