alxrt
14.05.2012 19:02
Чуваки, как сделать это лучшь и пизже?
SELECT distinct basename as bn,
(
select sum(all_traffic) from traffic WHERE src_ip in
(
select ip from resolves where basename = bn
)
) as t_sum
FROM resolves group by bn order by t_sum desc;
точно говнокод.
если у тебя distinct basename as bn, то group by bn не делает ничего
Можно как-то так:
select resolves.basename as bn, sum(traffic.all_traffic) as t_sum from resolves join traffic on resolves.basename = traffic.basename group by basename order by t_sum desc;
ой, "on resolves.ip = traffic.src_ip"
ШТО ЗА ГОВНО?!