<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jxy.marketall.mapper.HolderBalanceMapper">


	<select id="getNewHolderBalance" resultType="com.jxy.marketall.dto.HolderBalanceDto">
        SELECT
			DATE_FORMAT(unixdt,'%Y-%m-%d') AS dateTime,
			holder_balance_0 ,
			holder_balance_1 ,
			holder_balance_2 ,
			holder_balance_3 ,
			holder_balance_4 ,
			holder_balance_5 ,
			holder_balance_6 ,
			holder_balance_7 ,
			holder_balance_15 ,
			holder_balance_30 ,
			holder_balance_60 ,
			holder_balance_90 ,
			holder_balance_180 ,
			holder_balance_360 as holderBalance1y,
			holder_balance_540 as holderBalance1p5y,
			holder_balance_720 as holderBalance2y,
			holder_balance_1080 as holderBalance3y,
			holder_balance_1440 as holderBalance4y,
			holder_balance_1800 as holderBalance5y,
			holder_balance_2160 as holderBalance6y,
			holder_balance_2520 as holderBalance7y,
			holder_balance_2880 as holderBalance8y,
			holder_balance_3240 as holderBalance9y,
			holder_balance_3600 as holderBalance10y,
			holder_balance_3960 as holderBalance11y
		FROM
			`holder_balance3`
		ORDER BY
			unixdt DESC
			LIMIT 1
		</select>

	<select id="getHolderBalanceByTime" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.HolderBalanceDto">
        SELECT
			DATE_FORMAT(unixdt,'%Y-%m-%d') AS dateTime,
			holder_balance_0 ,
			holder_balance_1 ,
			holder_balance_2 ,
			holder_balance_3 ,
			holder_balance_4 ,
			holder_balance_5 ,
			holder_balance_6 ,
			holder_balance_7 ,
			holder_balance_15 ,
			holder_balance_30 ,
			holder_balance_60 ,
			holder_balance_90 ,
			holder_balance_180 ,
			holder_balance_360 as holderBalance1y,
			holder_balance_540 as holderBalance1p5y,
			holder_balance_720 as holderBalance2y,
			holder_balance_1080 as holderBalance3y,
			holder_balance_1440 as holderBalance4y,
			holder_balance_1800 as holderBalance5y,
			holder_balance_2160 as holderBalance6y,
			holder_balance_2520 as holderBalance7y,
			holder_balance_2880 as holderBalance8y,
			holder_balance_3240 as holderBalance9y,
			holder_balance_3600 as holderBalance10y,
			holder_balance_3960 as holderBalance11y
		FROM
			`holder_balance3`
		<where>
			<if test="vo.start != null and vo.start != ''">
				and date_format(unixdt,'%y%m%d') = date_format(#{vo.start},'%y%m%d')
			</if>
		</where>
		limit 1
		</select>
</mapper>
