Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda