SQLTeam.com | Weblogs | Forums

Select query to show just 1 row with total count


#1

I want to run the count(*) query to get result just 1 single row. getting unique distinct docindex_i count from the table, table has 431k row count in total, but there are multiple rows with same docindex_i , just want to see a unique total row count with distinct docindex_i.
how to use the below conditions. getting error.

select COUNT(*) from (select distinct docindex_i from [docudeck]);

Thanks a lot for the helpful info


#2
create table dbo.docudeck(docindex_i int not null) insert into docudeck select 898989 union select 898989 union select 898989 union select 898989 union select 898989 union select 898989 union select 898989 union select 898989 union select 232 select COUNT(distinct docindex_i) from [docudeck] group by docindex_i select COUNT(*) from (select distinct docindex_i from [docudeck] ) a group by docindex_i drop table dbo.docudeck

#3

Sorry tried your query, is not working, bringing results with multiple rows,


#4

yes multi rows because all rows are not the same see the last one

select 232


#5

SELECT COUNT(DISTINCT docindex_i) from [docudeck];