Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

485
Visualizações
Trim Intermediate spaces in a string in Postgres

In the result, want only intermediate spaces to be removed.

Need to print only first part before hypen (-) along with Percentages.

Can you please help.

Input String: AMAZON - 25%; SAP - XXXXX - 45%; MICROSOFT - XXX&YYY - 30%

Query:

SELECT 
translate(left("S_Name",POSITION(',' IN "S_Name")-1),'(,),{,},"','') as FirstPart,
translate(SUBSTRING ("S_Name",length("S_Name") -4 ,4),'(,),{,},"','')as secondpart;
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

regexp_split_to_table can be used to split the value into strings by the delimiter ;, then you can use split_part to get the first and second parts of the desired result.

Select trim(split_part(t,' - ',1)) As First,
       trim(reverse(split_part(reverse(t),' - ',1))) As Second
From regexp_split_to_table('SUCCESS FACTORS - 25%; SAP - XXXXX - 45%; MICROSOFT - XXX&YYY - 30%', ';') As t;

Data Output:

first second
SUCCESS FACTORS 25%
SAP 45%
MICROSOFT 30%
over 4 years ago · Santiago Trujillo Relatório

0

Split the initial string by ; into a 'table' and then use regular expressions to extract the needed parts into columns.

select 
    trim(substring(s from '^([\w ]+)')) "first",
    substring(s from '([\d]+%)$') "second"
from unnest(string_to_array('SUCCESS FACTORS - 25%; SAP - XXXXX - 45%; MICROSOFT - XXX&YYY - 30%', ';')) s;
first second
SUCCESS FACTORS 25%
SAP 45%
MICROSOFT 30%
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda