测试:
select
avg(WEIGHT),TEST_DATE
from
data_weight
where
`SOURCE`='108'
and date_format(test_date,'%Y%m%d')>='20160926'
and date_format(test_date,'%Y%m%d')<='20160927'
and `USERID`='CFA2FC3C8E784CCCB5E5DB5F708FD859'
group by
date_format(test_date,'%Y%m%d')
ORDER BY
test_date
后台需要转码
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
String startTime1 = sdf.format(startTime);
String endTime1 = sdf.format(endTime);
mybatis中的内容:
select
avg(moisture) moisture,
avg(ADIPOSE_RATE) ADIPOSE_RATE,
avg(BONE_MASS) BONE_MASS,
avg(VISCERAL_FAT) VISCERAL_FAT,
TEST_DATE
from
data_bodycomposition
where
`SOURCE`=#{source}
and date_format(test_date,'%Y%m%d')>=#{startTime}
and date_format(test_date,'%Y%m%d')<=#{endTime}
and `USERID`=#{userId}
group by
date_format(test_date,'%Y%m%d')
ORDER BY
TEST_DATE
desc
另外还附上本人处理float类型的方法, 容易忘记
float a = 123.2334f;
float b = (float)(Math.round(a*100))/100;(这里的100就是2位小数点,如果要其它位,如4位,这里两个100改成10000)