怎么根据年份统计数据库中各列的总值

数据库里面只有时间字段(包括年月日),资产名称,资产数量,资产金额,学校名称,怎样
按年度统计统计每年学校的资产总数,总金额,会的能提点下么?,求指点,能告诉大概
的方法,思路都好,在线等,谢谢 (java)

 class Record{
    private String dateStr = "";
    private String schoolName = "";
    private int money = 0;
    public Record(String dateStr,String schoolName,int money){
        this.dateStr = dateStr;
        this.schoolName = schoolName;
        this.money = money;
    }
    public String getYear() {
        return dateStr.split("-")[0];
    }
    public String getSchoolName() {
        return schoolName;
    }
    public int getMoney() {
        return money;
    }

}
public class Test { 
    public List<Record> init(){
        List<Record> list = new ArrayList();
        list.add(new Record("2015-01-01","学校A",200));
        list.add(new Record("2015-02-01","学校A",300));
        list.add(new Record("2015-03-01","学校A",400));
        list.add(new Record("2015-01-01","学校B",200));
        list.add(new Record("2015-01-01","学校B",600));
        list.add(new Record("2015-02-01","学校B",800));
        return list;
    }
    public HashMap<String,HashMap<String,Integer>> tongJi(List<Record> list){
        HashMap<String,HashMap<String,Integer>> rstMap = new HashMap();
        for(int i=0;i<list.size();i++){
            Record rd = list.get(i);
            if(rstMap.get(rd.getYear())==null){
                rstMap.put(rd.getYear(),new HashMap());                 
            }
            HashMap<String,Integer> schoolMap= rstMap.get(rd.getYear());
            if(schoolMap.get(rd.getSchoolName())==null){
                schoolMap.put(rd.getSchoolName(),0);      
            }
            Integer value = schoolMap.get(rd.getSchoolName());
            value = value + rd.getMoney();
            schoolMap.put(rd.getSchoolName(),value);      
        }
        return rstMap;
    }
    public void print(HashMap<String,HashMap<String,Integer>> rstMap){
        Iterator  iter1 = rstMap.keySet().iterator();
        while(iter1.hasNext()){
            String year = (String)iter1.next();
            HashMap<String,Integer> schoolMap= rstMap.get(year);
            Iterator iter2 = schoolMap.keySet().iterator();
            while(iter2.hasNext()){
                String schoolName = (String)iter2.next();
                int value = schoolMap.get(schoolName);
                System.out.println("year="+year+",school="+schoolName + ",金额="+value);
            }
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
         Test t = new  Test();
         List<Record> list = t.init();
         HashMap map = t.tongJi(list);//统计
         t.print(map);
    }

}
 select sum(资产金额) from 表 group by 学校名称,年份(日期取年,数据库都有对应的函数)

sql中的sum(字段名)就能实现这个功能