标签:app 相同 version sel div join 记录 group sts
1.
SELECT a.* FROM app a WHERE a.app_version = (SELECT MAX(b.app_version) FROM app b WHERE b.app_name = a.app_name) ORDER BY a.app_name;
2.
SELECT a.* FROM app a WHERE NOT EXISTS(SELECT 1 FROM app b WHERE b.app_name = a.app_name AND b.app_version > a.app_version) ORDER BY a.app_name;
3.
SELECT a.* FROM app a, (SELECT app_name, MAX(app_version) AS app_version FROM app GROUP BY app_name) b WHERE a.app_name = b.app_name AND a.app_version = b.app_version ORDER BY a.app_name;
4.
SELECT a.* FROM app a INNER JOIN (SELECT app_name, MAX(app_version) AS app_version FROM app GROUP BY app_name) b ON a.app_name = b.app_name AND a.app_version = b.app_version ORDER BY a.app_name;
标签:app 相同 version sel div join 记录 group sts
原文地址:http://www.cnblogs.com/huey/p/6145662.html