Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在“一个查询”中,您可以使用 HAVING 子句:
select sales_id, max(revision) from Sales group by sales_id having max(revision) = 0; select sales_id, max(revision) from Sales group by sales_id having max(revision) = 1;
我在 SqlFiddle 中添加了您的查询,您可以查看执行计划以了解差异。
SqlFiddle