I have a table like this:
ID country
-------------
1 US
2 Japan
3 China
4 US
5 China
How can one query the table, so that it returns how many different countries are in the table (i.e 3)?
6条答案
按热度按时间5gfr0r5j1#
The following SQL query will result in counting the number of unique countries in your table.
nkkqxpd92#
What you need is to select the amount of unique countries. This is done by selecting all country entries, which are then grouped so there is only one country entry per country name.
SELECT count(country) from countrytable group by country;
This is basically the same as Andomars answer.
pb3s4cty3#
you can use this
Output :
0yg35tkg4#
从国家/地区表中选择计数(不同的国家/地区)
r55awzrz5#
select count(distinct country) from table1
watbbzwu6#
从[TableName]中选择计数(不同国家/地区)