zOs/SQL/CATTBPAH
select dbName db
, count(*) tot
, sum(case when year(statstime) = 2011 then 1 else 0 end) y11
, sum(case when year(statstime) = 2010 then 1 else 0 end) y10
, sum(case when year(statstime) = 2009 then 1 else 0 end) y09
, sum(case when year(statstime) = 2008 then 1 else 0 end) y08
, sum(case when year(statstime) = 2007 then 1 else 0 end) y07
, sum(case when year(statstime) = 2006 then 1 else 0 end) y06
, sum(case when year(statstime) < 2006 then 1 else 0 end) b05
from sysibm.SYSTABLEPART_HIST
group by dbName
with ur
;;;