<?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.ETHV2Mapper">

	<select id="getListByTableAndField" resultType="com.jxy.marketall.dto.DateBigDecimalDto" statementType="STATEMENT">
		SELECT distinct
		unixdt as date,
		${field} as value
		FROM
		   ${table}
		ORDER BY
		unixdt
	</select>
    <select id="getCDD" resultType="com.jxy.marketall.dto.ETHCoinDaysDescDto">
		SELECT
		unixdt as date,
		cdd1,cdd7,cdd30,cdd60,cdd90,cdd180,cdd365,cdd730
		from
		 dailyindsv2na
		order by
		unixdt
	</select>
	<select id="getAddressBalance" resultType="com.jxy.marketall.dto.ETHAddressBalanceDto">
		SELECT
			unixdt as date,
			address_balance_nozero nozero,
			address_balance_1 balance1,
			address_balance_10 balance10,
			address_balance_100 balance100,
			address_balance_1k balance1k,
			address_balance_10k balance10k
		from
		 	dailyindsv2na
		order by
			unixdt
	</select>

	<select id="getAddressSupply" resultType="com.jxy.marketall.dto.ETHAddressBalanceDto">
		SELECT
			unixdt as date,
			balance_nozero nozero,
			balance_1 balance1,
			balance_10 balance10,
			balance_100 balance100,
			balance_1k balance1k,
			balance_10k balance10k
		from
		 	dailyindsv2na
		order by
			unixdt
	</select>

	<select id="getPriceList" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.PriceDataDto">
		SELECT distinct
			unixdt as time,
			price as value
		FROM
			dailyindsv2na
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= "${vo.start}"
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= "${vo.end}"
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="getYearIssuance" resultType="com.jxy.marketall.dto.YearMaDto">
		select date_format(unixdt,"%Y") AS `year`,sum(issuance) `value` from dailyindsv2na group by `year`;
	</select>

    <select id="getCsupplyList" resultType="com.jxy.marketall.dto.DateBigDecimalDto">
		SELECT distinct
		unixdt as date,
		csupply as value
		FROM
		dailyindsv2na
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= "${vo.start}"
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= "${vo.end}"
			</if>
		</where>
		ORDER BY
		unixdt
	</select>


</mapper>
