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

182
Views
¿Cómo limitar la cantidad de filas para cada valor?

Estos son mis datos de muestra.

 Date Name Subject Importance Location Time Rating 12/08/2020 David Work 1 London - - 1/08/2020 David Work 3 London 23.50 4 2/10/2018 David Emails 3 New York 18.20 3 12/08/2020 George Updates 2 New York - - 1/08/2019 George New Appointments5 London 55.10 2 2/10/2019 David Emails 3 Paris 18.58 3 8/09/2017 David Emails 2 Paris 18.90 5

Necesito poder ver las reuniones de mañana y las 3 reuniones anteriores que he tenido con cada cliente. Por lo tanto, se ordenará por nombre, luego por fecha con las entradas limitadas por nombre a 3. ¿Podría alguien indicarme la dirección correcta para poder hacer esto?

El resultado esperado sería

 Date Name Subject Importance Location Time Rating 12/08/2020 David Work 1 London - - 1/08/2020 David Work 3 London 23.50 4 2/10/2018 David Emails 3 New York 18.20 3 2/10/2019 David Emails 3 Paris 18.58 - 12/08/2020 George Updates 2 New York - - 1/08/2019 George New Appointments5 London 55.10 2
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede utilizar funciones de ventana para contar el número de reuniones de las próximas tres que son "mañana". Y luego un poco de filtrado:

 select t.* from (select t.*, count(*) filter (where date = current_date + interval '1 day') over (partition by name order by date rows between 1 following and 3 following ) as cnt_tomorrow from t ) t where date = current_date + interval '1 day' or cnt_tomorrow > 0 order by name, date;

Aquí hay un db<>fiddle.

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!