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

173
Vistas
count rows with x value node.js

I have this:

if (rows[i]["SUB_STATUS"] == "ACTIVE") {
   console.log("status is " + rows[i]["SUB_STATUS"])
 } else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
    console.log("status is inactive " + rows[i]["SUB_STATUS"])
}

and I want to count the number of rows that my table holds with rows[i]["SUB_STATUS"] = to inactive, and active. How is this possible?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Without having more context, I can't tell exactly how you want this information stored. However, it is rather simple to keep a count of occurrences. You can store the number of times you encounter either of these situations in variables.

let numActive = 0;
let numInactive = 0;

if (rows[i]["SUB_STATUS"] == "ACTIVE") {
   numActive++;
   console.log("status is " + rows[i]["SUB_STATUS"])
 } else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
    numInactive++;
    console.log("status is inactive " + rows[i]["SUB_STATUS"])
}

// Do something with these values
console.log('Number of active:', numActive);
console.log('Number of inactive:', numInactive)

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