My data consists of annual tables for many workers (e.g. a file2006
,file2007
) incl. an employer ID as well as a firm ID. I also made a view to group firms by some calculations (groups
below), which seem to complete fine so they are not shown. However, I thought I had the query to calculate the change in the total wage bill for each firm from 2006 to 2007 by these grouping using the code below. Instead of the blazing fast calculation of the previous views, this stalls the system for long, and finally breaks with some error message about mapping problems. What is the right way to do this then?
CREATE VIEW sys.change2007 (firmid,groups,wagebillchange) AS (
SELECT file2006.firmid,MAX(groups.groups), (
SELECT SUM(file2007.wage)/SUM(file2006.wage) FROM file2006, file2007
WHERE file2006.firmid = file2007.firmid
)
FROM file2006, file2007, groups
WHERE file2006.firmid = file2007.firmid AND file2006.peorglopnr = groups.firmid
GROUP BY file2006.firmid
);