I have some trouble getting my query right for a specific output.
My table looks like this:
ID | meta_value | field_id | item_id
------------------------------------
1 | Steve | 75 | 5
2 | Johnsson | 76 | 5
3 | Sick | 705 | 5
4 | John | 75 | 6
5 | Doe | 76 | 6
6 | Sick | 705 | 6
7 | Laura | 75 | 7
8 | Jenner | 76 | 7
9 | Sick | 705 | 7
10 | Laura | 75 | 8
11 | Jenner | 76 | 8
12 | Vacation | 705 | 8
13 | Steve | 75 | 9
14 | Johnsson | 76 | 9
15 | Sick | 705 | 9
And I want to merge - group by item_id and their combined meta_value - and count the results, where the value is "Sick" - Order by count, as follows:
Name: Sick (Count):
Steve Johnsson 2
John Doe 1
Laura Jenner 1
(Vacation is left out)
I think I've tried all possible combination, but obviously nothing seems to be right. (Changing the table is not an option). I've been trying for hours...
Please help :)
Thanks in advance!
Steve Johnssonis2andJohn Doeis1.