select t.MchntID,
        m.MchntName, 
      t.CheckDate,   
      to_number(t.BeginMoney) BeginMoney,        
        to_number(t.EndMoney) EndMoney,       
        to_number(t.InMoney) InMoney,       
        to_number(t.RtnMoney) RtnMoney,     
        to_number(t.FixMoney) FixMoney,     
        to_number(t.TranMoneyCM) TranMoneyCM,     
        to_number(t.TranCountCM) TranCountCM,     
        to_number(t.TranMoneyCUN) TranMoneyCUN,   
      to_number(t.TranCountCUN) TranCountCUN,     
      to_number(t.TranMoneyCTC) TranMoneyCTC,     
      to_number(t.TranCountCTC) TranCountCTC,     
        to_number(t.TranMoneyTotal) TranMoneyTotal,     
        to_number(t.TranCountTotal) TranCountTotal,  
        to_number(t.BeginMoney)+to_number(t.InMoney)+to_number(t.RtnMoney)-to_number(t.FixMoney)-to_number(t.EndMoney)-to_number(t.TranMoneyTotal) as hedui     
   from user_checkinfo t,m_merchant m  
   where t.mchntid = m.mchntid 
   and (beginmoney<>'0' or inmoney <> '0' or  endmoney<>'0' or rtnmoney<>'0' or fixmoney<>'0' or trancounttotal<>'0')    
   and t.checkdate='20110623'
   order by hedui  desc; 

解决方案 »

  1.   


    select * from (
    select t.MchntID,
      m.MchntName,  
      t.CheckDate,   
      to_number(t.BeginMoney) BeginMoney,   
      to_number(t.EndMoney) EndMoney,   
      to_number(t.InMoney) InMoney,   
      to_number(t.RtnMoney) RtnMoney,   
      to_number(t.FixMoney) FixMoney,   
      to_number(t.TranMoneyCM) TranMoneyCM,   
      to_number(t.TranCountCM) TranCountCM,   
      to_number(t.TranMoneyCUN) TranMoneyCUN,   
      to_number(t.TranCountCUN) TranCountCUN,   
      to_number(t.TranMoneyCTC) TranMoneyCTC,   
      to_number(t.TranCountCTC) TranCountCTC,   
      to_number(t.TranMoneyTotal) TranMoneyTotal,   
      to_number(t.TranCountTotal) TranCountTotal,   
      to_number(t.BeginMoney)+to_number(t.InMoney)+to_number(t.RtnMoney)-to_number(t.FixMoney)-to_number(t.EndMoney)-to_number(t.TranMoneyTotal) as hedui   
      from user_checkinfo t,m_merchant m   
      where t.mchntid = m.mchntid  
      and (beginmoney<>'0' or inmoney <> '0' or endmoney<>'0' or rtnmoney<>'0' or fixmoney<>'0' or trancounttotal<>'0')   
      and t.checkdate='20110623'
    ) as temp
      order by temp.hedui desc;