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.
我有一张带有纬度、经度和美国州字段的位置表。我想选择每个州的平均纬度和经度。
我正在尝试以下代码,但在 distinct 上出现语法错误。
select avg(lat), avg(lon), distinct(state) from tRealtyTrac order by state group by state
你不需要独特的。如果您按州分组,无论如何您都会得到一个结果
很确定您也需要在 order by 子句之前使用 group by 子句。
select state, avg(lat), avg(lon) from tRealtyTrac group by state order by state