I have 3 tables, first one with different instruments (instruments), second one with different sets (sets) and the last one with the 2 primary keys (many-to-many). So a set can contain multiple instruments and an instrument can be in multiple sets.
Additionally I have the column "amount" in my many-to-many table. So a set can contain a specific instrument multiple times. Basically I want to know the total amount of the instruments in sets and display all the instruments including their amount in a gallery sorted descending by the amount- here is an example:
InstrumentID SetID Amount
Instrument_A Set_B 1
Instrument_B Set_B 2
Instrument_A Set_A 3
Instrument_C Set_C 4
Instrument_A Set_C 2
So the Instrument_A should be listed at first with total amount of 6, Instrument_C second with amount of 4 and Instrument_B third with amount of 2.