You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
813 B
30 lines
813 B
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)
|
|
|
|
<k> "q1" </k>
|
|
|
|
SELECT max(price-min(timestamp)) FROM stocks
|
|
<k> "q2" </k>
|
|
|
|
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
|