Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by hub.org (8.9.2/8.9.1) with ESMTP id LAA02762 for ; Thu, 25 Mar 1999 11:52:49 -0500 (EST) (envelope-from oleg@sai.msu.su) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.9.1/8.9.1) with ESMTP id TAA06148 for ; Thu, 25 Mar 1999 19:52:42 +0300 (MSK) Date: Thu, 25 Mar 1999 19:52:42 +0300 (MSK) From: Oleg Bartunov X-Sender: megera@ra To: pgsql-sql@postgreSQL.org Subject: [SQL] Subselect has too many or too few fields Message-ID: Organization: Sternberg Astronomical Institute (Moscow University) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=koi8-r Content-Transfer-Encoding: 8bit I have a problem with query I thought must works: c_flats=> select source, max(up_date) as max_update, count(*) from flats where u up_date in (select max(up_date) from flats group by source) group by source; ERROR: parser: Subselect has too many or too few fields. Internal subselect produces as expected: c_flats=> select max(up_date) from flats group by source; max ---------- 15-03-1999 11-03-1999 24-03-1999 24-03-1999 24-03-1999 And I don't see a reason my query doesn't works. If I substite the result of internal subselect I get what I need (there are cyrillic characters in ) c_flats=> select source, max(up_date) as max_update, count(*) from flats where u p_date in ('15-03-1999','11-03-1999','24-03-1999','24-03-1999','24-03-1999') gro up by source; source |max_update|count --------------------------+----------+----- éîëïí 369-00-25, 365-10-38|15-03-1999| 674 ëÏÒÎÅÔ 912-00-12 |11-03-1999| 47 íéáî 974-62-62 |24-03-1999| 393 íéüìø 217-30-20, 217-39-13|24-03-1999| 1 íãâî |24-03-1999| 141 (5 rows) Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83