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.
AQuery/tests/q4.a

40 lines
1.2 KiB

create table ticks(id varchar(20), timestamp int, tradeDate date, price int)
load data infile "data/stocksym_price.csv"
into table ticks fields terminated by ","
-- select max(price - mins(price))
-- from ticks assuming asc timestamp
-- where ID = "S" and tradeDate= '01-10-22';
select max(price - mins(price))
from ticks assuming asc timestamp
where ID = "S" and tradeDate= '2022-10-01';
DROP TABLE IF EXISTS ticks
CREATE TABLE ticks(ID varchar(20), date int, endofdayprice int)
LOAD DATA INFILE "data/ticks.csv" INTO TABLE TICKS FIELDS TERMINATED BY ","
SELECT max(endofdayprice/prev(endofdayprice)) as Max_Ratio
FROM ticks
ASSUMING ASC date
WHERE ID = "3001"
CREATE TABLE ticks2(ID VARCHAR(20), max REAL, min REAL)
INSERT INTO ticks2 SELECT ID AS ID, max(ratios(endofdayprice)) AS max, min(ratios(endofdayprice)) AS min from ticks group by ID;
SELECT ID, max, min
FROM ticks2;
CREATE TABLE my_table (c1 INT, c2 INT, c3 STRING)
INSERT INTO my_table VALUES(10, 20, "example")
select * from my_table;
INSERT INTO my_table SELECT * FROM my_table
select * from my_table;
SELECT c1, c2 as twice_c2 FROM my_table;
CREATE TABLE my_table_derived
AS
SELECT c1, c2 as twice_c2 FROM my_table;
SELECT * FROM my_table_derived;