Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Eliminating Duplicates using Distinct Keyword

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 238
    Comment on it

    DISTINCT Keyword:

    It is used to fetch different values from a table. It removes duplicate records from the result set and used when there can be multiple duplicate tuples in a table.

    Syntax:

    SELECT DISTINCT columnname FROM tablename;
    

    Example:

    The below query will fetch different name and salary from Employee table as it will not return duplicate names.

    SELECT DISTINCT(name),salary FROM Employee;
    
    Name Salary
    ---------- ----------
    Sam 25000
    Ashley 35000
    Robert 25000
    Chris 25000

    As we can see from the above example no duplicate names are fetched from the table just because of DISTINCT keyword used with name column.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: