select substr(xzqh, 1, 4)||'00',count(JGMC) from organization t where t.tj_type like 'A%' group by sjnf,substr(xzqh, 1, 4) 上面还少了年份是最近的这个条件,应该怎么写?
select substr(地区编号, 1, 4),count(名称) from table where 类别 like 'A%' and 年份=to_char(sysdate,'yyyy') group by substr(地区编号, 1, 4)试试
加上一个年份 = select max(年份) from tab
现在用 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) 可以了,谢谢各位!
上面还少了年份是最近的这个条件,应该怎么写?
from table
where 类别 like 'A%'
and 年份=to_char(sysdate,'yyyy')
group by substr(地区编号, 1, 4)试试
from tab
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)
可以了,谢谢各位!