Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Distinct keyword in Oracle SQL

This is a discussion on Distinct keyword in Oracle SQL within the SQL forums, part of the Databases category; Hi, I have one doubts in using the Distinct keyword to suppress the duplicates from the performance point of view. Why we should not use the Distinct Keyword in the ...

Go Back   Geeks Talk > Databases > SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 03-28-2008
Junior Member
 
Join Date: Oct 2006
Location: chennai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ily_saravanan is on a distinguished road
Distinct keyword in Oracle SQL

Hi,

I have one doubts in using the Distinct keyword to suppress the duplicates from the performance point of view. Why we should not use the Distinct Keyword in the Select statement. To suppress the duplicate, which one is the best to use to avoid the duplication.

while using the Distinct keyword in select clause, I am getting an Performance problem.

If any body knows, please let me know.

Thanks in advance.


Thanks,
Saravanan.P
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-29-2008
Expert Member
 
Join Date: Sep 2007
Posts: 738
Thanks: 22
Thanked 67 Times in 65 Posts
krishnaindia2007 is on a distinguished road
Re: Distinct keyword in Oracle SQL

Quote:
Originally Posted by ily_saravanan View Post
Hi,

I have one doubts in using the Distinct keyword to suppress the duplicates from the performance point of view. Why we should not use the Distinct Keyword in the Select statement. To suppress the duplicate, which one is the best to use to avoid the duplication.

while using the Distinct keyword in select clause, I am getting an Performance problem.

If any body knows, please let me know.

Thanks in advance.


Thanks,
Saravanan.P
To eliminate duplicate records you may use group by instead of using distinct as follows

SQL> SELECT DISTINCT DEPTNO,JOB FROM EMP;

DEPTNO JOB
--------- ---------
10 CLERK
10 MANAGER
10 PRESIDENT
20 ANALYST
20 CLERK
20 MANAGER
30 CLERK
30 MANAGER
30 SALESMAN

9 rows selected.

SQL> SQL> SELECT DEPTNO, JOB, COUNT(*) FROM EMP
2 GROUP BY DEPTNO,JOB;

DEPTNO JOB COUNT(*)
--------- --------- ---------
10 CLERK 1
10 MANAGER 1
10 PRESIDENT 1
20 CLERK 2
20 ANALYST 2
20 MANAGER 1
30 CLERK 1
30 MANAGER 1
30 SALESMAN 4

9 rows selected.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
difference bet unique and distinct smitai Oracle Certification 4 1 Week Ago 08:35 AM
Load Distinct and Duplicate values to different targets tanya123 Data Warehousing 1 02-25-2008 09:06 PM
ASM keyword in C language Geek_Guest C and C++ 1 08-21-2007 02:01 AM
Alternative for SELECT DISTINCT to query 2 million records Geek_Guest SQL 1 08-06-2007 09:29 AM
"like" keyword in oracle.. psuresh1982 Oracle 5 12-22-2006 10:19 AM


All times are GMT -4. The time now is 03:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved