我在Mysql中的表是这样的:
IP ID area
aaa A I
aaa A I
aaa B I
aaa C II
bbb A I
bbb B III
ccc B I
现在我想计算每个区域的值,有多少不同的(IP,ID)对?
如何使用IP和ID作为整个数据集来执行此操作?
我不认为以下查询是正确的:
SELECT area, count (distinct IP, ID) from video GROUP BY area ORDER BY COUNT (distinct ip, ID)
所以有人知道怎么做吗?
答案 0 :(得分:1)
SELECT count(*), CONCAT_WS(' ',IP,ID) as yourTitle FROM video GROUP BY yourTitle
应该
答案 1 :(得分:0)
SELECT area, count(*) as distinctCount FROM
(SELECT DISTINCT IP, ID, area FROM video) distinctVideos
GROUP BY area
ORDER BY count(*)