Home > Net >  How can I cut the 1st letter from a cell and add to another cell in PSQL?
How can I cut the 1st letter from a cell and add to another cell in PSQL?

Time:02-07

I have a long list, and I want to add the first letter into another cell with psql command.

A header Another header
John J
Lila L
Dwane D
Zaba Z
Kiol K
Longi L
Uthe U
Hell H

Like this.

CodePudding user response:

You can use the left() postgres function to extract the first charater from a string, see the manual. Try something like this :

SELECT "A header", left("A header", 1) AS "Another header"
  FROM your_table
  •  Tags:  
  • Related