SELECT * FROM option_list o WHERE future_list
SELECT o.date FROM option_list o IN (SELECT DATE FROM future_list f WHERE deal_cash >= 10000000000)

-- 특정 시간부터 30초 동안 현재가와 죄소값, 최대값
SELECT o.fin_price 
FROM option_list o 
WHERE o.date='2015-06-18 14:50:01'

SELECT o.fin_price, MAX(o.fin_price), MIN(o.fin_price)
FROM option_list o 
WHERE o.date>='2015-06-18 14:50:01' AND o.date<=DATE_ADD('2015-06-18 14:50:01', INTERVAL 30 SECOND)


-- 100억이상의 거래량이 나온 시간의 옵션
SELECT sl.* FROM 
(SELECT o.* FROM option_list o LEFT OUTER JOIN future_list f ON o.date=f.date AND f.deal_cash >= 10000000000) AS sl


-- 100억이상의 거래량이 나온 시간의 옵션과 향후 30초 동안의 옵션들
SELECT sl.deal_cash, sl.date, o2.date, o2.fin_price
FROM
	(SELECT f.deal_cash, o.date FROM option_list o LEFT OUTER JOIN future_list f ON o.date=f.date AND f.deal_cash >= 10000000000) AS sl
	LEFT OUTER JOIN option_list o2
	ON o2.date>=sl.date AND o2.date<=DATE_ADD(sl.date, INTERVAL 30 SECOND)
	
	
-- 100억이상의 거래량이 나온 시간의 옵션과 향후 30초 동안의 옵션들 중 fin_price, min, max
SELECT sl.deal_cash, sl.date, o2.date, sl.fin_price, MIN(o2.fin_price), MAX(o2.fin_price)
FROM
	(SELECT f.deal_cash, o.date, o.fin_price
	FROM option_list o LEFT OUTER JOIN future_list f 
	ON o.date=f.date AND f.deal_cash >= 10000000000) AS sl
	LEFT OUTER JOIN option_list o2
	ON o2.date>=sl.date AND o2.date<=DATE_ADD(sl.date, INTERVAL 30 SECOND)
GROUP BY sl.date


-- procedure
insert into futopt_list(deal_cash, date, fin_price)

SELECT f.deal_cash as deal_cash, o.date as date, o.fin_price as fin_price
	FROM future_list f LEFT OUTER JOIN option_list o
	ON f.deal_cash >= 10000000000 and o.date!=null
	
	
select * from futopt_list


create procedure futopt.FindBigDeal()
BEGIN