Click here to Skip to main content
12,254,393 members (60,645 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.5K views
4 bookmarked
Posted

COUNT of DISTINCT Rows in SQL Server

, 26 Nov 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Nice tip :)But if you have any column say empid which have the unique constraint then it is better to use the following SQL queryselect count(distinct empid ) from employees

Nice tip Smile | :)

But if you have any column say empid which have the unique constraint then it is better to use the following SQL query

select count(distinct empid ) from employees

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Vivek Johari
Technical Lead
India India
I am currently working as a Analyst and have around 7.5 years of experience in database.

Degree:-
Master Degree in Computer(MCA)

Work experience:-
Designing of the database.
Database Optimization.
Writing Complex Stored Procedures,Functions,Triggers etc.
Designing and developing SSIS & DTS packages.
Designing SQL Reports using SSRS.
Database Server Maintenance.

Certification:-
Microsoft certified Sql DBA in Sql server 2008 (MCTS).
Microsoft certified BI professional in Sql server 2008 (MCTS).
Oracle certified profession DBA in ORACLE 10g (OCP)
certified profession DBA in ORACLE 9i (OCP)

My other publication
Technical Blog:- Technologies with Vivek Johari

Moderator and Blogger at BeyondRelational.com

Guest Author and Blogger at sqlservercentral.com

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 1 Might work, who knows. It's not clea... Pin
Simon Dufour1-Dec-10 3:16
memberSimon Dufour1-Dec-10 3:16 
GeneralReason for my vote of 3 gud 1 Pin
ravindra_dhakate@rediffmail.com29-Nov-10 3:39
memberravindra_dhakate@rediffmail.com29-Nov-10 3:39 
GeneralYes, for specific column(s) list, DISTINCT works, but for '*... Pin
mravikiran27-Nov-10 12:09
membermravikiran27-Nov-10 12:09 
Yes, for specific column(s) list, DISTINCT works, but for '*' we dont have that luxury.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 26 Nov 2010
Article Copyright 2010 by Vivek Johari
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid