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

133
Vistas
How to split column values before grouping them using sqlite and sequelize?

I'm fairly new to JavaScript and don't know how to perform the following action. I have a table named info in the database which is similar to below

id city description
10 Paris some desc
2 New York some desc
4 Munich some desc
7 Paris;2 some desc
17 Munich;2 some desc

I want to get the highest id based on the city so I have written this filter which gets called using await models.city.findAll(options);

if (filtered) {
  options.where = {
     id: {
       $in: models.sequelize.literal('SELECT MAX(id) from info GROUP BY city'), 
    },
  };
 }

Now as you can see the following works only if the city field was not overloaded by in my case some other processes modifies that and concatenates a number with ; used as a delimiter.

What I want to do is for this filter to work by grouping by city and splitting using the delimiter to avoid getting duplicates.

I'm not sure how to do this using sequelize as I'm fairly new to this.

about 4 years ago · Juan Pablo Isaza
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