Assume I have a table with data and having a column with a date value and an affinity column, which can have 5 different values (i.e. a,b,c,d,e).
Table A
table_id date affinity
So I need to count how many entries there is per month of the year per affinity. So what I did, I initially created an sql query for each month per affinity, so the database gets opened for about 60 times, which is too much for most android phones to handle and is super slow.
I would like to know how I can condense this in a single query and then how I can get the values. Ideally I would be creating a temporary table that looks like this with sample values.
Jan Feb Mar Apr May ...
a 2 4 6 4 1
b 4 1 3 4 0
c 2 2 4 2 0
d 7 3 6 0 5
e 9 5 1 9 8
I am not well versed with advanced sql querying, but I do know of JOINS and nested SELECTS. So I just need a little push in the right direction. How can I achieve this?
Aucun commentaire:
Enregistrer un commentaire