-- use traffic;

select
	out.dstIp as server,
	out.trafOut as trafOut,
	in.trafIn as trafIn
from
	(
		select dstIp, sum(psize) as trafOut
		from traffic
		where (protoId=2) && (srcPort=0) && (srcIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by dstIp
	) as `out` join
	(
		select srcIp, sum(psize) as trafIn
		from traffic
		where (protoId=2) && (dstPort=0) && (dstIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by srcIp
	) as `in` on out.dstIp=in.srcIp

union all

select
	out.dstIp as server,
	out.trafOut as trafOut,
	ifnull(in.trafIn,0) as trafIn
from
	(
		select dstIp, sum(psize) as trafOut
		from traffic
		where (protoId=2) && (srcPort=0) && (srcIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by dstIp
	) as `out` left outer join
	(
		select srcIp, sum(psize) as trafIn
		from traffic
		where (protoId=2) && (dstPort=0) && (dstIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by srcIp
	) as `in` on out.dstIp = in.srcIp
where in.srcIp is null

;

/*
union all

select
	in.srcIp as server,
	ifnull(out.trafOut,0) as trafOut,
	in.trafIn as trafIn
from
	(
		select dstIp, sum(psize) as trafOut
		from traffic
		where (protoId=2) && (srcPort=0) && (srcIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by dstIp
	) as `out` right outer join
	(
		select srcIp, sum(psize) as trafIn
		from traffic
		where (protoId=2) && (dstPort=0) && (dstIp=3232241011) &&
			(date >= "2009-05-01" && date < "2009-06-01")
		group by srcIp
	) as `in` on out.dstIp = in.srcIp
where out.dstIp is null;
*/
