Yagya
Yagya

Reputation: 29

SQL query customized output

I have below query:

   select 'my.MYNAME=' + name  from hostnames;

   my.MYNAME=abc
   my.MYNAME=xyz
   my.MYNAME=poi

The query is dynamic is gives3 result, it may give more result depending upon data.

I need following output:

my.MYNAME1=abc
my.MYNAME2=xyz
my.MYNAME3=poi

Numbers appending to MYNAME according to result it gives.

I have tried

select 'my.MYNAME={c}' + name  from hostnames where (select count(*) as c from name);

but it is not working.

Upvotes: 0

Views: 850

Answers (1)

justMe
justMe

Reputation: 2428

One way to go about it is:

SELECT CONCAT(CONCAT(CONCAT('my.MYNAME',ROWNUM),'='), name) FROM hostnames

DEMO

Upvotes: 3

Related Questions