Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 938 → Rev 939

/sun/TrafficCount/trunk/sql/report_per_month.sql
0,0 → 1,31
select (date ('2003-' || month || '-01')) as the_date,
round((
(
select base + delta from tcount
where source = 'tun0_out'
and host = 'sun'
and stamp = (
select max(stamp) from tcount
where date_trunc('month', stamp) = date_trunc('month', date ('2003-' || month || '-01'))
and source = 'tun0_out'
and host = 'sun'
)
)
-
COALESCE((
select base + delta from tcount
where source = 'tun0_out'
and host = 'sun'
and stamp = (
select max(stamp) from tcount
where date_trunc('month', stamp)
= date_trunc('month', date ('2003-' || month || '-01')) - interval '1 month'
and source = 'tun0_out'
and host = 'sun'
)
), 0)
) / 1024 / 1024)
as count
from tmonths m
order by the_date;