So I have a table of 146510 rows. The schema and sample data are given below.
create table test2 (
year char(4)
qtr char(2),
area char(6),
industry char(3),
employment numeric(8,0)
);
2014,01,000019,722513,324
2014,02,000019,722513,330
2014,03,000019,722513,311
2014,04,000019,722513,347
2014,00,000019,722513,328
For every distinct combination of year, qtr, area, and industry, I need to produce a yearly average. The issue that I am running into is figuring out how to have it produce a 5th quarter. At the moment, there are 4 rows (due to having four quarters) per every combination of area and industry. I need to produce a fifth row that will have a q5 (or some value that represents average). First question is if there is a need to use the select distinct command? Second, do I use update to produce this fifth row?
↧