1.nvl(sum(cco.amount),0)
2.sum(case when sai.expense_name='燃油附加费' and sai.arap_Type='0' then sai.amount else 0 end )arryf_amount
3.decode(sai.arapType,'0',sai.amount,0)==decode(sign(sai.arapType-'0'),0,sai.amount,0)
sign(a-b)函数根据某个值是0、正数还是负数,分别返回0、1、-1.sign函数将两个比较的数转化成数字再比较.参数a和b可以是数字也可能是字符.
4.MIN/MAX
自动编号 学号 姓名 课程编号 课程名称 分数
1 2005001 张三 0001 数学 69
2 2005002 李四 0001 数学 89
3 2005001 张三 0001 数学 69
删除除了自动编号不同,其他都相同的学生冗余信息
答案是: delete tablename where 自动编号 not in(select min(自动编号) from tablename group by 学号,姓名,课程编号,课程名称,分数)
select cco.receiveOrderTime,nvl(sum(sai.amount),0),sai.customerName,cco.uaBillNo,cco.transportateTime,cco.customerName,cco.consignId,cco.custVoucherId,cco.urgent,cco.transMode,cco.fetchProvince,cco.fetchCity,cco.receiverProvince,cco.receiverCity,cco.receiver,cco.fetchCarrierName,cco.signforTime,cco.receiptor,cco.totalQty,cco.totalVol,cco.totalWeight,cco.calWeight,cco.memo,cco.businessType from CoConsignOrder cco left join cco.stArapItems sai where (sai.arapType='0' or sai.arapType is null) and cco.customerNo='SBMV' and cco.receiveOrderTime>=TO_DATE('2008-05-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and cco.receiveOrderTime<=TO_DATE('2008-05-30 23:59:59','YYYY-MM-DD HH24:MI:SS') group by cco.receiveOrderTime,sai.customerName,cco.uaBillNo,cco.transportateTime,cco.customerName,cco.consignId,cco.custVoucherId,cco.urgent,cco.transMode,cco.fetchProvince,cco.fetchCity,cco.receiverProvince,cco.receiverCity,cco.receiver,cco.fetchCarrierName,cco.signforTime,cco.receiptor,cco.totalQty,cco.totalVol,cco.totalWeight,cco.calWeight,cco.memo,cco.businessType order by cco.receiveOrderTime ASC
hibernate分组后计算总记录数似乎只用q.list().size()...郁闷中