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;

1. gelraen 14.05.2012 20:18

точно говнокод.
если у тебя 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;

2. gelraengelraen /1 14.05.2012 20:44

ой, "on resolves.ip = traffic.src_ip"

3. utros 14.05.2012 22:34 pedobook

ШТО ЗА ГОВНО?!

Do you really want to delete ?