Re: Results with leading zero - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: Results with leading zero
Date
Msg-id 20080616062145.GB26025@a-kretschmer.de
Whole thread Raw
In response to Results with leading zero  (novice <user.postgresql@gmail.com>)
Responses Re: Results with leading zero  (novice <user.postgresql@gmail.com>)
List pgsql-sql
am  Mon, dem 16.06.2008, um 11:48:01 +1000 mailte novice folgendes:
> I have a table
> 
> CREATE TABLE problem (
>   problem_id  integer,
>   solution_count integer
>   );
> 
> INSERT INTO problem VALUES (1001, 4);
> INSERT INTO problem VALUES (1012, 11);
> 
> SELECT * from problem;
> 
>  problem_id | solution_count
> ------------+---------------
>        1001 |             4
>        1012 |            11
> (2 rows)
> 
> 
> Is there a way I could write a query to produce the following?  I will
> need the leading zero for solution < 10
> 
>  problem_id | solution
> -------------+------------
>         1001 | 01
>         1001 | 02

My previous answer was a little bit wrong (no leading zero for solution
< 10), sorry. But no problem:

select problem_id, to_char(generate_Series(1,solution_count),'09') as solution_count from problem ;



Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Results with leading zero
Next
From: novice
Date:
Subject: Re: Results with leading zero