上圖T1
要有如下T2的效果
這是t2
select c.ip,ip1,ip2 from (
select a.ip as ip,a.ip1,b.ip2 from
(
select ip,ip1
from test4 where (ip2 is null and ip1 is not null) or(ip1 is not null and ip2 is not null)
) a
inner join
(select ip,ip2
from test4 where (ip1 is null and ip2 is not null) or(ip1 is not null and ip2 is not null)
) b on a.ip=b.ip) c
用這種方式可以達到效果,但是test4有幾十萬條數據會不會影響運行 效果,不知有沒有更好的方法????
select ip,max(ip1),max(ip2) from t1 group by ip