SELECT pcode,
ver,
monthday,
fncode,
country,
province,
dognum,
gid,
mac,
hardwareid,
ip,
rank() OVER (PARTITION BY pcode,ver,monthday,fncode,gid ORDER BY if(province='未知',2,1)) as rank_gid,
rank() OVER (PARTITION BY pcode,ver,monthday,fncode,mac ORDER BY if(province='未知',2,1)) as rank_mac,
rank() OVER (PARTITION BY pcode,ver,monthday,fncode,hardwareid ORDER BY if(province='未知',2,1)) as rank_hardwareid,
rank() OVER (PARTITION BY pcode,ver,monthday,fncode,ip ORDER BY if(province='未知',2,1)) as rank_ip
FROM
(SELECT pcode,
ver,
monthday,
fncode,
country,
province,
dognum,
gid,
mac,
hardwareid,
ip
FROM
uv_logs
GROUP BY pcode,ver,monthday,fncode,country,province,dognum,gid,mac,hardwareid,ip) a
上面红字部分去掉,然后在执行下
|