Run the following command in MySQL: Select use_city, count (*) from data where OS = "Windows 2003 STD" group by use_city; the result is:
+ ----------- + ---------- +
| Use_city | count (*) |
+ ----------- + ---------- +
| Beijing | 2 |
| Chengdu | 2 |
| Chongqing | 1 |
| Dalian | 2 |
| Fuzhou | 2 |
| Guangzhou | 2 |
| Hangzhou | 2 |
| Nanjing | 2 |
| Shanghai | 21 |
| Shenyang | 5 |
| Wuhan | 1 |
+ ----------- + ---------- +
11 rows in SET (0.01 Sec)
There are a total of 11 records. The problem is that there is no matching record for "Tianjing" in one of the cities. How can I display it
+ ----------- + ---------- +
| Use_city | count (*) |
+ ----------- + ---------- +
| Beijing | 2 |
| Chengdu | 2 |
| Chongqing | 1 |
| Dalian | 2 |
| Fuzhou | 2 |
| Guangzhou | 2 |
| Hangzhou | 2 |
| Nanjing | 2 |
| Shanghai | 21 |
| Tianjing | 0 |
| Shenyang | 5 |
| Wuhan | 1 |
+ ----------- + ---------- +
Show the records whose count is 0 as follows:
Select
Use_city,
Count (case when OS = 'windows 2003 STD 'Then 1 else null end)
From
Data
Group
Use_city