I want to ask to join 2 tables. I have first table like this :
|idsite | nmsite |
-------------------
| 1 | nm1 |
| 2 | nm2 |
| 3 | nm3 |
--------------------
and the second table is :
|idsite | iddetsite | dataA | dataB | dataC | time |
----------------------------------------------------------------
| 1 | 1 | 3 | 4 | 5 | 2015-01-01|
| 1 | 2 | 3 | 2 | 3 | 2015-02-01|
| 1 | 3 | 5 | 3 | 2 | 2016-01-01|
| 1 | 4 | 5 | 3 | 2 | 2016-02-01|
| 2 | 5 | 2 | 5 | 3 | 2015-02-02|
| 2 | 6 | 5 | 3 | 2 | 2016-04-02|
| 3 | 7 | 7 | 1 | 1 | 2015-01-01|
| 3 | 8 | 3 | 3 | 3 | 2016-02-02|
----------------------------------------------------------------
The result for dataA should be:
| time | nm1 | nm2 | nm3 |
------------------------------------
| 2015 | 6 | 2 | 7 |
| 2016 | 10 | 5 | 3 |
------------------------------------
ket: nm1 in the result table is sum(dataA) by year, anyone can help me?, it is different question, I ask in third table or the result table, there are 4 columns, times from 2 table, and nm1,nm2,nm3 from 1 table field, so the third table is the result where the data field from 1 table will be the header column in 3 table(result table), i think this is the different kind. Thanks