------------------------------sql------------------------------
SELECT(CASE WHEN POPULATION_MODEL.age<=14 THEN '0-14岁'
WHEN POPULATION_MODEL.age>14 and POPULATION_MODEL.age<=64 THEN '14-64岁'
WHEN POPULATION_MODEL.age>64 THEN '65岁及以上'
END)ranges,STREET_NAME, COUNT(1) count , 100*round(COUNT(*)/SUM(COUNT(*)) OVER(),3) percent from POPULATION_MODEL where POPULATION_MODEL.age is not null GROUP BY (CASE WHEN POPULATION_MODEL.age<=14 THEN '0-14岁'
WHEN POPULATION_MODEL.age>14 and POPULATION_MODEL.age<=64 THEN '14-64岁'
WHEN POPULATION_MODEL.age>64 THEN '65岁及以上'
END),STREET_NAME ORDER BY STREET_NAME
--------------------dao -----------------------
private Object getStatisticsData(String customSql,Dao dao){
Sql sql = Sqls.create(customSql);
Sql callbackSql = sql.setCallback(Sqls.callback.records());
dao.execute(sql);
Object result = callbackSql.getResult();
return result;
}
问答
分组统计自定义sql 数据库可以查询出来数据,nutz不能查出来,这个dao方法简单的sql能查询数据
标签:
无
4 回复
这个是哪个运行sql的日志
Can't identify SQL type : SELECT(CASE WHEN POPULATION_MODEL.age<=14 THEN '0-14岁' WHEN POPULATION_MODEL.age>14 and POPULATION_MODEL.age<=64 THEN '14-64岁'WHEN POPULATION_MODEL.age>64 THEN '65岁及以上'END)ranges,STREET_NAME, TO_CHAR(COUNT(1)) rs from POPULATION_MODEL where POPULATION_MODEL.age is not null GROUP BY (CASE WHEN POPULATION_MO
添加回复
请先登陆