Monday 15 June 2015

how to create an extra column and rows using select query in postgresql -



how to create an extra column and rows using select query in postgresql -

following sample of trying accomplish (never mind select query because show actual problem)

for example,

select col1 from( select 'tab09' col1 union select 'tab09_01' union select 'tab09_02' union select 'tab09_03' union select 'tab09_04' ) t order col1

will return

col1 ---------- tab09 tab09_01 tab09_02 tab09_03 tab09_04

so, postgresql function helps result below

col1 col2 ----------+---------- tab09 tab10 tab09_01 tab10_01 tab09_02 tab10_02 tab09_03 tab10_03 tab09_04 tab10_04

select col1,overlay(col1 placing '10' 4 2) col2 from( --your select query goes here ) t order col1

       

overlay-postgresql doc

postgresql

No comments:

Post a Comment