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

201
Visualizações
Is there a printf like function in mysql

This is a hackerRank THEPADS problem.

The question is query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:

There are a total of 2 doctors.

There are a total of 2 singers.

There are a total of 3 actors.

There are a total of 3 professors.

the occupations table goes like this

CREATE TABLE occupations(name varchar(100),Occupation varchar(100));

so how can i print this format is there any printf like function in mysql

Here is the image of the records present in occupations table: here is the image of the records present in occupations table

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can use concat method to append and group by and count function to get number for each occupation

SELECT "There are a total of ", count(OCCUPATION), concat(lower(occupation),"s.") FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY count(OCCUPATION), OCCUPATION ASC
over 4 years ago · Santiago Trujillo Relatório

0

Just to clarify. There is sucha function and it's SELECT. You can print things like this:

SELECT "Hello world" as "";

or

SELECT "Hello world" as ""\G;

There is no way to remove the : prefix in the second case.

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