X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C295CD9BAB for ; Mon, 21 Nov 2005 08:47:39 -0400 (AST) 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 14597-08 for ; Mon, 21 Nov 2005 12:47:41 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sapo.pt (relay3.ptmail.sapo.pt [212.55.154.23]) by svr1.postgresql.org (Postfix) with SMTP id C98B7D9ABB for ; Mon, 21 Nov 2005 08:47:36 -0400 (AST) Received: (qmail 23292 invoked by uid 0); 21 Nov 2005 12:47:38 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.152) by relay3 with SMTP; 21 Nov 2005 12:47:38 -0000 Received: (qmail 28093 invoked from network); 21 Nov 2005 12:47:38 -0000 X-AntiVirus: PTMail-AV 0.3.87.1 X-Virus-Status: Clean (0.00784 seconds) Received: from unknown (HELO hmv02) (hmv@[82.155.151.100]) (envelope-sender ) by mta2 (qmail-ldap-1.03) with SMTP for ; 21 Nov 2005 12:47:38 -0000 Message-ID: <000901c5ee99$c275e380$580bfea9@hmv02> From: =?iso-8859-1?Q?H=E9lder_M._Vieira?= To: Subject: max() unexpected type conversion Date: Mon, 21 Nov 2005 12:47:40 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.258 required=5 tests=[AWL=0.022, RCVD_IN_SORBS_WEB=1.236] X-Spam-Score: 1.258 X-Spam-Level: * X-Archive-Number: 200511/178 X-Sequence-Number: 23429 Hello. I'm having some trouble with an unexpected conversion performed by the max() function. If max() operates on a 'varchar' type column, the result appears with 'text' type. Should I expect this behaviour in the current and later versions ? I mention this because I'm using ODBC in VB, and this type conversion has a bad outcome, because 'text' columns require a specific treatment (a second reading of the column contents returns null). Therefore, if this conversion is beeing made as a result of a design option, I'll have to use a different approach (something like 'select ... order by ... desc limit 1'). A small sample follows, giving a 'text' type result: create table test ( testcol varchar(4) not null ); insert into test (testcol) values ('A'); insert into test (testcol) values ('A'); insert into test (testcol) values ('B'); insert into test (testcol) values ('B'); insert into test (testcol) values ('C'); insert into test (testcol) values ('C'); select max(testcol) from test; Thank you Hélder M. Vieira