avatar
help about SQL for ACCESS# Database - 数据库
g*o
1
Does anybody help me take a look of following SQL statement
select distinct count(column_name) from table name;
what I want is the unique count number for given column. but it returns
me all of the count ( not unique count).
This statement works fine against Oracle, but not for ACCESS.
thanks very much.
avatar
g*o
2
finally got the answer.
MS ACCESS does not support SELECT COUNT(DISTINCT COLUMN_NAME ) FROM
TABLE_NAME,
but we can use subquery to get the DISTINCT COUNT NUMBER.
the query is
SELECT COUNT(column_name) FROM
(SELECT DISTINCT column_name FROM table_name).

【在 g***o 的大作中提到】
: Does anybody help me take a look of following SQL statement
: select distinct count(column_name) from table name;
: what I want is the unique count number for given column. but it returns
: me all of the count ( not unique count).
: This statement works fine against Oracle, but not for ACCESS.
: thanks very much.

avatar
z*e
3
SELECT COUNT(column_name) FROM table_name GROUP BY column_name
Is it same?

【在 g***o 的大作中提到】
: finally got the answer.
: MS ACCESS does not support SELECT COUNT(DISTINCT COLUMN_NAME ) FROM
: TABLE_NAME,
: but we can use subquery to get the DISTINCT COUNT NUMBER.
: the query is
: SELECT COUNT(column_name) FROM
: (SELECT DISTINCT column_name FROM table_name).

avatar
g*o
4
I think these two queries get different recordsets.
for instance, we have following table
county company
2 A
3 A
4 A
2 B
3 B
4 B
5 B
2 C
your query get this result:
county count
2 3
3 2
4 2
5 1
my query get the result like:
count
4
the reason is that I get the count number of distinct county that exists in
this table,
while you get the count numb

【在 z****e 的大作中提到】
: SELECT COUNT(column_name) FROM table_name GROUP BY column_name
: Is it same?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。