Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!