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 739803A43FA for ; Sat, 20 Nov 2004 16:51:33 +0000 (GMT) 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 74680-07 for ; Sat, 20 Nov 2004 16:51:30 +0000 (GMT) Received: from nitrogenio.carvalhaes.net (oxigenio.carvalhaes.net [200.102.144.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7D0D03A428F for ; Sat, 20 Nov 2004 16:51:29 +0000 (GMT) Received: from [192.168.0.5] ([192.168.0.5]) (authenticated bits=0) by nitrogenio.carvalhaes.net (8.12.11/8.12.11) with ESMTP id iAKGijo5032089 for ; Sat, 20 Nov 2004 14:44:45 -0200 Message-ID: <419F5A83.1040504@carvalhaes.net> Date: Sat, 20 Nov 2004 14:53:55 +0000 From: Rodrigo Carvalhaes Reply-To: grupos@carvalhaes.net User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How to get the max on a char column? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Carvalhaes-MailScanner-Information: Please contact the ISP for more information X-Carvalhaes-MailScanner: Found to be clean X-MailScanner-From: grupos@carvalhaes.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/213 X-Sequence-Number: 19532 Hi ! I am quite confused of the results on a SELECT max... My environment: Conectiva Linux 10, PostgreSQL 7.4.6 (compiled from the sources) My problem is the "select max(id) FROM test" the result is 20 but the right is 1020. Is this a BUG or I am crazy ?? Cheers, Rodrigo Carvalhaes The SQL... teste=# CREATE TABLE test ( id char(15), name char(80) ); CREATE TABLE teste=# \d test Table "public.test" Column | Type | Modifiers --------+---------------+----------- id | character(15) | name | character(80) | teste=# INSERT INTO test VALUES ( '10', 'luidgi'); INSERT 15303727 1 teste=# INSERT INTO test VALUES ( '20', 'luis'); INSERT 15303728 1 teste=# INSERT INTO test VALUES ( '1010', 'ruan'); INSERT 15303729 1 teste=# INSERT INTO test VALUES ( '1020', 'lion'); INSERT 15303730 1 teste=# SELECT * FROM test; id | name -----------------+---------------------------------------------------------------------------------- 10 | luidgi 20 | luis 1010 | ruan 1020 | lion (4 rows) teste=# SELECT max(id) FROM test; max ----- 20 (1 row) teste=# select max(id) FROM test; max ----- 20 (1 row) ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org