From: Rodrigo Carvalhaes <grupos@carvalhaes.net>
To: pgsql-sql@postgresql.org
Subject: How to get the max on a char column?
Date: Sat, 20 Nov 2004 14:53:55 +0000
Message-ID: <419F5A83.1040504@carvalhaes.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: grupos@carvalhaes.net
Subject: Re: How to get the max on a char column?
In-Reply-To: <419F5A83.1040504@carvalhaes.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox