Skip to content
Advertisement

Perform calculation without having to do it manually for each column?

/////This question was deleted

Advertisement

Answer

if you want someone to provide you with a complete solution then you will need to supply:

  1. CREATE TABLE statements for the 3 tables
  2. INSERT INTO… statements to provide sample data for all 3 tables

However, if you just want a suggestion about how to approach this problem then I would use an UNPIVOT statement to create a view/table that

  • holds all the columns in dbo.T_BASE_GEMEINDE_BEVOELKERUNG_JAHR_BEGINN
    apart from the “year” columns (J2017, J2018, j2019, …)
  • adds a single “year” column with values from 2017 to 2050
  • adds a single value column to hold the population for each year

By joining your existing tables to this new table/view and grouping by your new “year” column you should achieve what you want

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement