sql code
小计 合计
StringBuilder strSql = new StringBuilder(); strSql.Append("select * from ( "); strSql.Append("select id,decla_id,customs_broker,unstuffing_group,tallyman,customer,customs_officer,ruku_time,ruku_way,ruku_storage,ruku_shell,goods_name,num,single_num,remark "); strSql.Append(" FROM dt_ruku "); strSql.Append(" union all select min(id), decla_id,null,null,null,null,null,null,null,null,null,goods_name='小计',sum(num)num,null,null from dt_ruku "); strSql.Append(" group by decla_id ) t "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by decla_id ,case goods_name when '小计' then 2 else 1 end "); return DbHelperSQL.Query(strSql.ToString());
order by case when bugosstate=0 then 'severity desc' else 'thedate desc' end 实现不同的 bugosstate = 0的时候 按 severity 排序 bugosstate<>0的时候 按thedate排序
小计 合计 -统计 http://www.cnblogs.com/zengxiangzhan/archive/2010/01/03/1638155.html