Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Results wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 3530 of 3797
Post > Topic >>

Re: Results with leading zero

by user.postgresql@[EMAIL PROTECTED] (novice) Jun 16, 2008 at 04:48 PM

Perfect!
Thank you very mcuh :)

2008/6/16 A. Kretschmer <andreas.kretschmer@[EMAIL PROTECTED]
>:
> 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
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
THINK BEFORE YOU PRINT - Save paper if you don't really need to print
this.

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 6 Posts in Topic:
Results with leading zero
user.postgresql@[EMAIL PR  2008-06-16 11:48:01 
Re: Results with leading zero
mail@[EMAIL PROTECTED] (  2008-06-16 07:19:30 
Re: Results with leading zero
andreas.kretschmer@[EMAIL  2008-06-16 08:11:02 
Re: Results with leading zero
andreas.kretschmer@[EMAIL  2008-06-16 08:21:45 
Re: Results with leading zero
user.postgresql@[EMAIL PR  2008-06-16 16:48:04 
Re: Results with leading zero
tsakai@[EMAIL PROTECTED]   2008-06-16 09:35:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 11:22:34 CST 2008.