设为车站中城市条目的个数,设为车站中不同城市名称的个数,查询起始车站的值。换句话说,找出表中城市条目的总数和表中不同城市条目的数量之间的差异。
输入格式
站点表描述如下:enter image description here
其中LAT_N是北纬,LONG_W是西经。
发布于 2017-08-19 02:14:29
在计数函数中使用distinct。
select count(city) - count(distinct city)
from station发布于 2020-12-14 17:21:32
SELECT count(city) - count(DISTINCT city) FROM station;不要忘记在查询后添加分号';‘
发布于 2017-08-19 01:51:48
您可以使用having在聚合函数上过滤结果
select city, count(*), count(distinct city)
from station
group by city
having count(*) <> count(distinct city)https://stackoverflow.com/questions/45762324
复制相似问题