X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 58FF852E5C for ; Fri, 12 Aug 2005 00:38:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77182-09 for ; Fri, 12 Aug 2005 03:38:32 +0000 (GMT) Received: from web33414.mail.mud.yahoo.com (web33414.mail.mud.yahoo.com [68.142.206.146]) by svr1.postgresql.org (Postfix) with SMTP id F048452E1A for ; Fri, 12 Aug 2005 00:38:31 -0300 (ADT) Received: (qmail 80534 invoked by uid 60001); 12 Aug 2005 03:38:30 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=4zQxu65Gj0aKmCgUS/jS8o4Z/BCowy1WtM5/mLj5ejX0gJCfNHQJfHnlj6W6AzGNjWP1m5J9Cyi29JKl8p58o/dyrEku2QwXFv8Ig6/46+xHOaeyw4mKNegxcAYSH+oAwrjsVFTIA0+TdBfr3nWMMEdKaIa1PBluMSbY+5/q6QI= ; Message-ID: <20050812033830.80532.qmail@web33414.mail.mud.yahoo.com> Received: from [222.124.69.59] by web33414.mail.mud.yahoo.com via HTTP; Thu, 11 Aug 2005 20:38:30 PDT Date: Thu, 11 Aug 2005 20:38:30 -0700 (PDT) From: Louise Catherine Subject: about subselect To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.999 tagged_above=0 required=5 tests=[AWL=1.214, DNS_FROM_RFC_ABUSE=0.374, FROM_HAS_MIXED_NUMS=0.298, FROM_HAS_MIXED_NUMS3=1.113] X-Spam-Level: ** X-Archive-Number: 200508/63 X-Sequence-Number: 22291 Hi, I make a subquery test at postgresql 7.3.3 and postgresql 8.0.3. I found that postgresql 8.0.3 can't do this, while at postgresql 7.0.3 it works quite well : create table temp_hasil2( nojob numeric, nik numeric, tanggal numeric, kdpt numeric, kdljr numeric ); create table ap012( nojob numeric, tglavd numeric, ptcd numeric ); create table am382( nojob numeric, nik numeric, tglavd numeric, lkrjacd numeric ); Update Temp_hasil2 Set KdPT = A.PTCD, KdLjr = A.LKRJACD From (Select A38.NIK,A01.ptcd,A38.Lkrjacd From AM382 A38 inner join ap012 A01 on A38.nojob = A01.nojob Where A38.tglavd = (select max(B38.tglavd) from am382 B38 where A38.nik = B38.nik and B38.tglavd <= Temp_hasil2.Tanggal) And A01.tglavd = (select max(B01.tglavd) from ap012 B01 where A01.nojob = B01.nojob and B01.tglavd <= A38.tglavd) )A Where Temp_hasil2.NIK = A.NIK; If I run this query at Postgresql 8.0.3 : Error: ERROR: subquery in FROM may not refer to other relations of same query level. Can someone help me solve this?, because I've a plan to migrate database from postgresql 7.3.3 to postgresql 8.0.3, and I have a lot of case like one above at my postgresql 7.3.3 databases. Thanks, Louise Catherine NB: Sorry for my poor English ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs