![]() | |
#11
| |||
| |||
|
|
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 |

#12
| |||
| |||
|
|
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 |

#13
| |||
| |||
|
|
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 |

#14
| |||
| |||
|
|
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 |

#15
| |||
| |||
|
|
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 |

#16
| |||
| |||
|
|
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 |

#17
| |||
| |||
|
|
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 |

![]() |
| Thread Tools | |
| Display Modes | |
| |