java - 数据库decimal类型的怎么和String类型的比大小?
ringa_lee
ringa_lee 2017-04-17 17:28:35
0
1
1034
String sql ="SELECT e.max,e.min,e.content,e.logo, sum(c.couponfee/100) FROM couponpublish c,couponpool s,hh_coupon_equivalent e  WHERE s.pubid=c.pubid AND s.status=3";
            List<Map> l = super.findListbySqlReturnMap(sql);
            for(int i=0;i<l.size();i++){
            double sum=(Double)list.get(i).get("sum(c.couponfee/100)");
            double max =(Double)l.get(i).get("max");
            double min = (Double)l.get(i).get("min");
                if(sum>min&&sum<max){
                    e.put("content",'2');
                }
            }
            
            max 和min是decimal类型,sum是string类型,他们3个怎么比大小
ringa_lee
ringa_lee

ringa_lee

全部回覆(1)
洪涛

都轉換成 BigDecimal 來比較大小啊,

String sql ="SELECT e.max,e.min,e.content,e.logo, sum(c.couponfee/100) FROM couponpublish c,couponpool s,hh_coupon_equivalent e  WHERE s.pubid=c.pubid AND s.status=3";
List<Map> l = super.findListbySqlReturnMap(sql);
for(int i = 0; i < l.size(); i++){
    BigDecimal sum= new BigDecimal(list.get(i).get("sum(c.couponfee/100)"));
    BigDecimal max = new BigDecimal(l.get(i).get("max"));
    BigDecimal min = new BigDecimal(l.get(i).get("min"));
    if(sum.compareTo(min) > 0 && sum.compareTo(max) < 0){
        e.put("content",'2');
    }
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板