News for hackers. Stuff that matters.
Re:PRQL, Pipelined Relational Query Language by slt2021 on Wednesday July 26, 2023 @01:49PM (#36881876)
queries like these are best suited for window functions, although I am not sure Mysql supports it:

  SELECT article, dealer, price FROM (
    SELECT *, ROW_NUMBER() OVER (PARTITION BY article ORDER BY price DESC) as rnk
    FROM   shop s1
  ) sub 
  WHERE sub.rnk=1
  ORDER BY article; 
this query will be a single pass over table without loops/joins

There are no comments on this comment yet.