using MMoneyCoderSharp.Data.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MMoneyCoderSharp.DBDefine;

namespace MMoneyCoderSharp.DB
{
    /// <summary>
    /// </summary>
    internal class Grid11 : ADataObject
    {
     
        /// <summary>
        /// 금일 데이터 쿼리
        /// </summary>
         string queryToday = @"select '코스피' name, 
		decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')  invest_name,
		round((sum(F_SELL_turnover) - sum(F_BUY_turnover)) / 100000000)  amt
		from t_invest
	where F_PART_CODE = '001'
		and F_INVEST_CODE in('1000', '2000', '3000', '4000', '6000')
		group by decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')
		union
		select '코스닥' name,
		decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')  invest_name,
		round((sum(F_SELL_turnover) - sum(F_BUY_turnover)) / 100000000)  amt
		from t_kosdaq_invest
	where F_PART_CODE = '001'
		and F_INVEST_CODE in('1000', '2000', '3000', '4000', '6000')
		group by decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')
		union
		select '코스피200' name,
		decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')  invest_name,
		round((sum(F_SELL_turnover) - sum(F_BUY_turnover)) / 100000000)  amt
		from t_invest
	where F_PART_CODE = '029'
		and F_INVEST_CODE in('1000', '2000', '3000', '4000', '6000')
		group by decode(f_invest_code, '1000', '증권', '2000', '보험',
			'3000', '투신',
			'4000', '은행', '6000', '기금')";

        public override IDataRequest buildData()
        {

            string bufQuery = "";

            bufQuery += String.Format(queryToday);

            mRequestQuery.Add("", bufQuery);

            return this;
        }
    }
}
