jgt05
jgt05

Reputation: 27

How to concatenate oracle sql output from a select query

Unable to concatenate output from SELECT statement query.

But I want something like:

SS = "start_" + [ID] from [Start Order = 1] ','  "ExecutionT" + [Start_Wait] 
SELECT 
    ID, Name, SName, Start_Order, Start_Wait
FROM
    File
WHERE 
    ZONE IN ('west') AND SNAME = 'DA'
ORDER BY 
    START_ORDER 

This is my current output:

ID                     SName      Name   Start_Order       Start_Wait
----------------------------------------------------------------------
i-001c9e54bc5a5fabc     DA      DevApp1     1                  3
i-03136748c823abdef     DA      DevApp2     2                  0
i-03c07d9e63eb53fgh     DA      DevApp3     3                  3

Upvotes: 0

Views: 180

Answers (1)

Popeye
Popeye

Reputation: 35910

You can concate the column valies as following:

Select col1 || col2 || 'some string' 
from your_table

|| is the concatanation operator in oracle.

Your query should look something like following. Please adjust the constant strings, if not according to your requirement.

SELECT 'SS = start_' 
|| ID 
|| ' from [Start Order = '
|| start_order
|| '] '',''  ExecutionT ['
|| Start_Wait
|| ']'
        from File
           WHERE ZONE IN ('west') AND SNAME = 'DA'
        ORDER BY START_ORDER 

Cheers!!

Upvotes: 1

Related Questions