Home > database >  Have the accumulative field table and another table coupling problem
Have the accumulative field table and another table coupling problem

Time:09-26

The diagram below, there are two tables, T1, T2
T1 structure is as follows, for the zoning code and year, accumulative park number

T2 following structure for zoning code, annual, forest area

Requirement is: now that binds two tables together, according to the division code equal conditions, among them, the number of parks should be like that, for example, T1 number in the park in 2001 for 6, 2008 to 12, after which, in 2001, the number of parks for 6, has been to the park in 2007 number for the same 6, when in 2008, 12, want to fall excuse me, how to join?
The resulting table structure, should be as the division code, annual, forest area, the accumulative number of parks,

CodePudding user response:

Partition outer join

CodePudding user response:

This problem is simpler, you put the table statements and test data are listed below,

CodePudding user response:

The range is vintage? Asked which one to which a year?

CodePudding user response:

refer to the second floor qq646748739 response:
the problem is simple, you put the table statements and test data are listed below,

This does not need to build table statements and test data, the whole list? Are the requirements for additional year such as the number of T1 park in 2001 to 8, 2008 to 12, no year data, then the same division code, table 2 all the years between 2002 and 2008, the park number is 8, because no increase in the middle,

CodePudding user response:

reference 1st floor weixin_38847048 response:
partition outer join

A little can speak more clearly, has examined the data, the feeling, but I put the cumulative number of park as a Partition by number (b. accumulative park) analysis of the object, the result is wrong,

CodePudding user response:

Can feel describe review, understanding is the area for 2001 to - 2007 park number unchanged (6), by 2008 to 12, beg park a total area of the eight years! Makes little sense to feel ah, is not the most widespread, area increase and meaning!
  • Related