Everybody latest data query time updates

Realization of ideas:inner join on + max() + group by

  1. The latest time is calculated by summing each set of the function max () and group by;
  2. Combining the original table generated by the step 1 inner join, the time selected by the latest piece of data on the conditions.

Implement SQL:
SELECT * FROM personData as table1 INNER JOIN (SELECT table2.named,max(table2.date) as max FROM personData as table2 WHERE county="历下区" GROUP BY table2.named) as table3 ON table1.named = table3.name AND table1.date=table3.max

Ideas bug: order by + group by;

Published 10 original articles · won praise 4 · Views 1140

Guess you like

Origin blog.csdn.net/qq_43314764/article/details/104556570