I have a table with different values for different countries, for example:
id| country | =================== 1 | Argelia | 2 | USA | 1 | China | 1 | Italy | 1 | Italy | 1 | USA | 4 | USA | 1 | Argelia |
I am interested in only one country’s count, and the total count, but I’m having trouble coming up with a single query to do it. The result of this query for id 1 would be:
id| value_in_Italy | total ========================== 1 | 2 | 6
As you can see, I obtained the value for Italy, and the total value. What kind of query would produce rows like the above for a similar table?
The simplest query that works on MySQL I can think of is:
MySQL doesn’t force you to
group by idas it will non-deterministically take one id, but thewhereclause is forcing that column to only have one id