Search code examples
plsqlconcatenation

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

Solution

  • 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.