ALTER TABLE logs.trades CHANGE recentprice price int;This is not supported by Athena apparently. You can drop the table and recreate it with the right column name.
ALTER TABLE trading_features.models RENAME COLUMN "indexchnge-20" TO "indexchange-20"This is not supported by Athena apparently.
ALTER TABLE logs.trades ADD COLUMN side stringSHOW PARTITIONS logs.tradesALTER TABLE logs.trades DROP PARTITION (year='2017',week='22',day='We')
DROP TABLE IF EXISTS logs.tradesselect count( distinct ticker) from trading_features.featuresI found that I had to cast each integer as doubles to divide and get two decimals.
SELECT round(cast(down AS double) / cast(total AS double),2) AS down FROM tradesSELECT 
 approx_percentile(close, 0.15) as low, 
 approx_percentile(close, 0.5) as mid, 
 approx_percentile(close, 0.85) as high 
FROM tablenameselect ticker from trading_features.features where upper(ticker) like '%A%'SELECT * FROM
  (SELECT ticker,
         count(*) AS total_trades,
         sum( IF(profit>0,
          1,
          0) ) AS plus,
         sum(IF(profit<0,
           1,
           0)) AS minus,
         cast(sum( IF(profit>0,
          1,
         0) ) AS double) / cast(count(*) AS double) AS pct
  FROM 
      (SELECT ticker,
           id,
           sum(price) AS profit
      FROM logs.trades
      GROUP BY  id, ticker) AS trades
  GROUP BY  ticker) as totals
WHERE total_trades > 20
ORDER BY pct DESC# Sums/Group By (2)
SELECT ticker,
         count(*) AS total_trades,
         sum(
           IF(profit>0,1,0)
         ) AS ups,
         sum(IF(profit<0,
         1,
         0)) AS downs
FROM 
    (SELECT ticker,
         id,
         sum(price) AS profit
    FROM logs.trades
    GROUP BY  id, ticker) AS trades
    GROUP BY  ticker
ORDER BY ups DESC
ORDER BY total_tradesWITH 
  grouped AS (SELECT 
   "mxc-1" as sequence,
   count(*) AS total,
         sum( IF(change='"down-flat"',
          1,
          0) ) AS df,
         sum(IF(change='"up-flat"',
           1,
           0)) AS uf,
         sum(IF(change='"up"',
           1,
           0)) AS up,
         sum(IF(change='"down"',
           1,
           0)) AS down
  FROM trading_features.models
  GROUP BY "mxc-1", change)
SELECT 
 grouped.sequence, 
 sum(grouped.total)as total, 
 sum(grouped.down) as down, 
 sum(grouped.df) as df, 
 sum(grouped.uf) as uf, 
 sum(grouped.up) as up
FROM groupedSELECT ticker, 
       sum(profit) as total_profit
FROM
  (SELECT 
  ticker,
  id,
       sum(price) as profit
  FROM logs.trades
  GROUP BY  id, ticker) as trades
 GROUP BY ticker
 ORDER BY total_profit DESCCREATE EXTERNAL TABLE IF NOT EXISTS logs.trades (
  `id` string,
  `model` string,
  `side` string,
  `ticker` string,
  `tickindex` string,
  `time` string,
  `recentprice` string 
) PARTITIONED BY (
  year string,
  weekOfYear string,
  dayOfWeek string 
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES (
  'serialization.format' = '1'
) LOCATION 's3://trading-logs-trades/trades/'
TBLPROPERTIES ('has_encrypted_data'='false')Use ""
SELECT "mxc-1",
FROM trading_features.models