I have the following table structure for storing the historical data .
CREATE TABLE `historical_data` (
`symbol_name` varchar(70) DEFAULT NULL,
`current_day` varchar(50) DEFAULT NULL,
`open_val` varchar(50) ,
`low_val` varchar(50) ,
`close_val` varchar(50) ,
`high_val` varchar(50) ,
`prevclose_val` varchar(50)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
And this is my sample data
From the current date i am trying to find out Top Losers for 1 week and 1 month from the current date
I have tried as following
select symbol_name, (prevclose_val-close_val) as losers from historical_data
order by losers asc limit 10
Could you please tell me how can i make this work for 1 week and 1 month .
The sample data wil be in this format
Insert Into historical_data values('SBIN','14-DEC-2015','300.10','289.00','305.10','309.90','256.30');
sql fiddle
http://sqlfiddle.com/#!9/47794
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…