fork(2) download
  1. CREATE TABLE air
  2. (id INT AUTO_INCREMENT, latlng varchar(50), pm int, datestamp datetime, PRIMARY KEY (id) )
  3. ;
  4. INSERT INTO air
  5. (latlng, pm, datestamp)
  6. values
  7. ('20,30', 10 , '2016-05-22 00:00:00') ,
  8. ('20,30', 50 , '2016-05-22 10:10:00') ,
  9. ('20,30', 40 , '2016-05-22 10:30:00') ;
  10. -- 原查詢語法: 舊紀錄在前
  11. -- SELECT * FROM `air`;
  12.  
  13. -- 查詢語法2: 新紀錄在前
  14. SELECT tmp.* FROM
  15. ( SELECT * FROM `air` ORDER BY `datestamp`
  16. ) tmp GROUP BY `latlng` ;
Success #stdin #stdout 0s 3396KB
stdin
Standard input is empty
stdout
|20,30|40|2016-05-22 10:30:00