|
|
|
CREATE TABLE stocks(timestamp INT, price INT)
|
|
|
|
|
|
|
|
INSERT INTO stocks VALUES(1,15)
|
|
|
|
INSERT INTO stocks VALUES(2,19)
|
|
|
|
INSERT INTO stocks VALUES(3,16)
|
|
|
|
INSERT INTO stocks VALUES(4,17)
|
|
|
|
INSERT INTO stocks VALUES(5,15)
|
|
|
|
INSERT INTO stocks VALUES(6,13)
|
|
|
|
INSERT INTO stocks VALUES(7,5)
|
|
|
|
INSERT INTO stocks VALUES(8,8)
|
|
|
|
INSERT INTO stocks VALUES(9,7)
|
|
|
|
INSERT INTO stocks VALUES(10,13)
|
|
|
|
INSERT INTO stocks VALUES(11,11)
|
|
|
|
INSERT INTO stocks VALUES(12,14)
|
|
|
|
INSERT INTO stocks VALUES(13,10)
|
|
|
|
INSERT INTO stocks VALUES(14,5)
|
|
|
|
INSERT INTO stocks VALUES(15,2)
|
|
|
|
INSERT INTO stocks VALUES(16,5)
|
|
|
|
|
|
|
|
SELECT max(price-min(timestamp)) FROM stocks
|
|
|
|
|
|
|
|
/*<k> "q1" </k>
|
|
|
|
*/
|
|
|
|
SELECT max(price-mins(price)) FROM stocks
|
|
|
|
SELECT price, timestamp FROM stocks where price - timestamp > 1 and not (price*timestamp<100)
|
|
|
|
|
|
|
|
/*
|
|
|
|
<k> "q3"</k>
|
|
|
|
SELECT max(price-mins(price))
|
|
|
|
FROM stocks
|
|
|
|
ASSUMING ASC timestamp
|
|
|
|
*/
|