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

252
Views
PostgreSQL: calcule el porcentaje de filas con una columna por encima de un cierto valor

Supongamos que tengo una tabla de valores:

 +----+-------+ | Id | Value | +----+-------+ | 1 | 2 | | 2 | 9 | | 3 | 5 | | 4 | 5 | | 5 | 8 | | 6 | 1 | +----+-------+

¿Cómo puedo calcular el porcentaje de filas cuyo valor es superior a un umbral determinado?

Por ejemplo, con un umbral de 'superior a 5' , ¿cómo podría consultar para obtener lo siguiente?

 +-------+------------------+ | Total | Percent above 5 | +-------+------------------+ | 6 | 33.33 | +-------+------------------+
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Usar agregación condicional:

 select count(*), avg( (value > 5)::int ) * 100 as percentage_above_5 from t;
over 4 years ago · Santiago Trujillo 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!