select *
from tab
where 类别 like 'A%'
group by 年份,substr(地区编号, 1, 4)

解决方案 »

  1.   

    select substr(xzqh, 1, 4)||'00',count(JGMC) from organization t where t.tj_type like 'A%' group by sjnf,substr(xzqh, 1, 4)
    上面还少了年份是最近的这个条件,应该怎么写?
      

  2.   

    select substr(地区编号, 1, 4),count(名称)
    from table
    where 类别 like 'A%'
    and 年份=to_char(sysdate,'yyyy')
    group by substr(地区编号, 1, 4)试试
      

  3.   

    加上一个年份 = select max(年份)
           from tab
      

  4.   

    现在用
    select substr(xzqh, 1, 4)||'00',count(JGMC) from organization t
          where t.tj_type like 'A%' and t.sjnf in (select max(tt.sjnf) as sjnf
           from organization tt ) group by substr(xzqh, 1, 4)
    可以了,谢谢各位!