problem description
Fields of the database:
uid, year, quarter, score
1 2018 4
1 2018 3
1 2018 3
2 2017 5
credits are counted on a quarterly basis, so points for a quarter need to be summed up.
the key of the first layer is uid, the key of the second layer is the year, the key of the third layer is the quarter, and the value is the integral and
s={1:{2018:{1:7,3:3}},2:{2017:{2:5}}}
the environmental background of the problems and what methods you have tried
I use json, but it is difficult to operate.
use the two-dimensional array
a = [1 br 2018, 1], [1, 2018, 1, 4], [2, 2017, 1, 7], [2, 2018, 2, 7]
when a [I] [0] = = a [j] [0] & a [I] [1] = = a [j] [1] & & a [I] [2] = a [j] [2]
ss=sum(a[i][3])
manipulate a two-dimensional array
related codes
/ / Please paste the code text below (do not replace the code with pictures)
what result do you expect? What is the error message actually seen?
forms this three-layer nested json, or other well-structured format.