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

89
Views
¿RANGO SQL pero más alto si es igual?

Para datos:

 20 50 50 60 70

Si uso RANK obtengo

 1 2 2 4 5

si uso DENSE_RANK obtengo

 1 2 2 3 4

Necesito para mi aplicación esto:

 1 3 3 4 5
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que quieres:

 rank() over(order by val) + count(*) over(partition by val) - 1

En realidad, esto sería más simple redactado con solo un recuento de ventanas:

 count(*) over(order by val)

Demostración en DB Fiddle :

 select val, count(*) over(order by val) rn from (values (20), (50), (50), (60), (70)) as t(val) order by val
valor | rn
--: | -:
 20 | 1
 50 | 3
 50 | 3
 60 | 4
 70 | 5
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!