From a sql database, I am reading a table with 2 fields: appName, user. So I may see:
+-------------+
| appA | John |
+-------------+
| appB | Mary |
+-------------+
| appC | Tom |
+-------------+
| appA | John |
+-------------+
| appA | Mary |
+-------------+
Each of these records is stored as an object of a AppClass with appName and user.
Now, i want to list how many times the apps were run by different users. So :
+-----------------+
| appA | John | 2 |
+-----------------+
| appA | Mary | 1 |
+-----------------+
| appB | Mary | 1 |
+-----------------+
| appC | Tom | 1 |
+-----------------+
Is it possible do the counting with a HashMap with 2 keys?
Yes, you can have a structure like the following:
But it’d be much easier if you just fetch the aggregated data directly from the database: