发布时间:2013-02-27 17:38:15
Select A.country,A.province,A.city, max(start_ip),min(start_ip),max(end_ip),min(end_ip) From
( Select (case when @cmname then @id:=@id+1 end) as none,
@id as sFlag,@c:=mname, a.start_ip,a.end_ip,a.country,a.province,a.city
from (select start_ip,end_ip,country,province,city,concat(country,province,city) as mname From t_wsd_ip order by start_ip asc ) a,(select @c:='',@id:=1 ) b ) A
Group by A.country,A.province,A.city,A.sFlag
SQL中使用变量。......【阅读全文】