dbTalk Databases Forums  

weird question

comp.databases.postgresql comp.databases.postgresql


Discuss weird question in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM






Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #12  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM






Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #13  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM



Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #14  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM



Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #15  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM



Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #16  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM



Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
  #17  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: weird question - 04-29-2008 , 06:55 AM



Andreas Kretschmer ha scritto:
Quote:
begin Coniglio Sgabbiato schrieb:
Hi, due to compatibility with legacy database codes I need to catenate
two numeric fields filling the gaps with zeros. For example take a table
with two numeric(5,0) fields, I need to catenate it in this way:

fld_a fld_b wanted_result
123 12345 0012312345
54 123 0005400123
5432 1234 0543201234

I am thinking about something like:

test=*# select * from n;
a | b
------+-------
123 | 12345
54 | 123
5432 | 1234
(3 rows)

test=*# select to_char(a,'FM09999')||to_char(b,'FM09999') as "wanted result" from n;
wanted result
---------------
0012312345
0005400123
0543201234
(3 rows)




end
Andreas
Thanks!, I did not know formatting functions in PG


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.