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

134
Views
obtener registros cuyo último registro vinculado tenga un valor específico

tengo este caso ingrese la descripción de la imagen aquí

donde hay 2 mesas:

libro por ejemplo

 id || -- 1 || 2 || 3 ||

y préstamo por ejemplo:

 id | booId | duration 1 | 1 | 4 2 | 1 | 6 3 | 1 | **5 (last one for book1)** 4 | 2 | 2 5 | 2 | 3 6 | 3 | 8 7 | 3 | **(5 not the last one so i don't need book3)** 8 | 3 | 6 9 | 2 | **5 (last one for book2)**

Necesito obtener la identificación de todos los libros, donde la duración del último préstamo es igual, por lo que en este ejemplo será: [1,2]

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Un método utiliza la agregación:

 select book_id from loans l group by book_id having max(id) = max(case when duration = 5 then id end);

Esto verifica que la última identificación de un libro determinado coincida con la última identificación de un libro determinado con la duración que desea.

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!