Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concat two column with '-' seperator in PL/SQL

I just want to concat two columns with seperator '-'.

These are the two columns, want to concat.

enter image description here

I am using this query to concat them

select concat(amt,endamt)as amount from mstcatrule

and it is giving me result this

enter image description here

But I Want that data of 2 columns should be sepearted by '-'

RESULT I WANT IS :

AMOUNT
0-0
100-99999999999
100-500
like image 413
Java_Alert Avatar asked Nov 28 '12 08:11

Java_Alert


2 Answers

Alternative:

select amt || '-' || endamt as amount from mstcatrule;
like image 74
Gumowy Kaczak Avatar answered Oct 24 '22 21:10

Gumowy Kaczak


Do it with two concats:

select concat(concat(amt, '-'), endamt) as amount from mstcatrule;

concat(amt,'-') concatenates the amt with the dash and the resulting string is concatenated with endamt.

like image 43
KeyNone Avatar answered Oct 24 '22 19:10

KeyNone