I'm writing a code in HIVE to create a table consisting of 1300 rows and 6 columns:
create table test1 as SELECT cd_screen_function,
SUM(access_count) AS max_count,
MIN(response_time_min) as response_time_min,
AVG(response_time_avg) as response_time_avg,
MAX(response_time_max) as response_time_max,
SUM(response_time_tot) as response_time_tot,
COUNT(*) as row_count
FROM sheet WHERE ts_update BETWEEN unix_timestamp('2012-11-01 00:00:00') AND
unix_timestamp('2012-11-30 00:00:00') and cd_office = '016'
GROUP BY cd_screen_function ORDER BY max_count DESC, cd_screen_function;
Now I want to add another column as access_count1
which consists one unique value for all 1300 rows and value will be sum(max_count)
. max_count is a column in my existing table. How I can do that? I am trying to alter the table by this code ALTER TABLE test1 ADD COLUMNS (access_count1 int) set default sum(max_count);