pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRETURN VALUES ON INTEGERS
4+ messages / 3 participants
[nested] [flat]
* RETURN VALUES ON INTEGERS
@ 1999-07-07 12:20 Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
0 siblings, 0 replies; 4+ messages in thread
From: Alessandro Rossi @ 1999-07-07 12:20 UTC (permalink / raw)
To: pgsql-sql
I have the following DATABASE.
CREATE TABLE codestatus (
id int primary key,
code int,
status char
);
code is an int number made at least of 6 numbers.
(range from 0 up to 999999)
If i do :
select * from codestatus;
I GET:
id|code|status
--+------+------
1| 44111|N
2| 123|S
BUT I WOULD LIKE TO GET
id|code|status
--+------+------
1|044111|N
2|000123|S
How could I fix the prbolem and get the values as I ned them out of the
select ?
thanks in advance
Alex
^ permalink raw reply [nested|flat] 4+ messages in thread
* RETURN VALUES ON INTEGERS
@ 1999-07-07 12:24 Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
1999-07-07 12:52 ` Re: [SQL] RETURN VALUES ON INTEGERS Herouth Maoz <herouth@oumail.openu.ac.il>
1999-07-07 14:36 ` RE: [SQL] RETURN VALUES ON INTEGERS John Ridout <johnridout@ctasystems.co.uk>
0 siblings, 2 replies; 4+ messages in thread
From: Alessandro Rossi @ 1999-07-07 12:24 UTC (permalink / raw)
To: pgsql-sql
I have the following DATABASE.
CREATE TABLE codestatus (
id int primary key,
code int,
status char
);
code is an int number made at least of 6 numbers.
(range from 0 up to 999999)
If i do :
select * from codestatus;
I GET:
id|code|status
--+------+------
1| 44111|N
2| 123|S
BUT I WOULD LIKE TO GET
id|code|status
--+------+------
1|044111|N
2|000123|S
How could I fix the prbolem and get the values as I ned them out of the
select ?
thanks in advance
Alex
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] RETURN VALUES ON INTEGERS
1999-07-07 12:24 RETURN VALUES ON INTEGERS Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
@ 1999-07-07 12:52 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1 sibling, 0 replies; 4+ messages in thread
From: Herouth Maoz @ 1999-07-07 12:52 UTC (permalink / raw)
To: Alessandro Rossi <alex@sunrise.radiostudiodelta.it>; pgsql-sql
At 15:24 +0300 on 07/07/1999, Alessandro Rossi wrote:
> I GET:
>
> id|code|status
> --+------+------
> 1| 44111|N
> 2| 123|S
>
> BUT I WOULD LIKE TO GET
>
> id|code|status
> --+------+------
> 1|044111|N
> 2|000123|S
>
> How could I fix the prbolem and get the values as I ned them out of the
> select ?
Try lpad. For example:
testing=> select num, lpad( num, 6, '0' ) from test1;
num| lpad
------+------
2|000002
4|000004
38|000038
199|000199
100399|100399
(5 rows)
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] RETURN VALUES ON INTEGERS
1999-07-07 12:24 RETURN VALUES ON INTEGERS Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
@ 1999-07-07 14:36 ` John Ridout <johnridout@ctasystems.co.uk>
1 sibling, 0 replies; 4+ messages in thread
From: John Ridout @ 1999-07-07 14:36 UTC (permalink / raw)
To: 'Alessandro Rossi' <alex@sunrise.radiostudiodelta.it>; pgsql-sql
> I have the following DATABASE.
>
> CREATE TABLE codestatus (
> id int primary key,
> code int,
> status char
> );
>
> code is an int number made at least of 6 numbers.
> (range from 0 up to 999999)
>
> If i do :
>
> select * from codestatus;
>
> I GET:
>
> id|code|status
> --+------+------
> 1| 44111|N
> 2| 123|S
>
> BUT I WOULD LIKE TO GET
>
> id|code|status
> --+------+------
> 1|044111|N
> 2|000123|S
>
> How could I fix the prbolem and get the values as I ned them
> out of the
> select ?
>
> thanks in advance
>
> Alex
>
Try
select id, lpad(code, 6, '0'), status
from codestatus
John
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-07-07 14:36 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-07-07 12:20 RETURN VALUES ON INTEGERS Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
1999-07-07 12:24 RETURN VALUES ON INTEGERS Alessandro Rossi <alex@sunrise.radiostudiodelta.it>
1999-07-07 12:52 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-07-07 14:36 ` John Ridout <johnridout@ctasystems.co.uk>
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