简体   繁体   English

如何对所有列一起使用计数和不同

[英]How to use count & distinct together for all columns

I am getting error while executing the following query.执行以下查询时出现错误。

SELECT COUNT(distinct *) AS "total unique records" FROM table

Please help me to resolve this issue请帮我解决这个问题

Because * is not allowed there. 因为那里不允许* If you want to do this, use a subquery: 如果要执行此操作,请使用子查询:

select count(*)
from (select distinct t.*
      from t
     ) t;

You probably want : 您可能想要:

select count(*)
from (select distinct t.*
      from table t
    ) t;

You should specify column's name, your query may contain more than one column. 您应该指定列的名称,您的查询可能包含多个列。

Example: SELECT COUNT(distinct Row1) AS "total unique records" FROM Table 示例:SELECT COUNT(distinct Row1)AS表中的“总唯一记录”

Use this code too count row 使用此代码也算行

 SELECT COUNT(*) AS TotalRecords FROM table 

AND use that too count row and return order columns 并且使用太计数行和退货订单列

 SELECT COUNT(*) OVER() AS TotalRecords,* FROM table 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM