Database Articles

  Home arrow Database Articles arrow Page 3 - Power Selecting
DATABASE ARTICLES

Power Selecting
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2004-12-20

    Table of Contents:
  • Power Selecting
  • Order By
  • Distinct
  • As
  • Like
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Power Selecting - Distinct


    (Page 3 of 6 )

    Occasionally one or more records may have the same information for a particular field and so a query may return duplicate results. As an example, consider a query to display the home states of those in the Clients table.

    SELECT State FROM Clients;

    State
    -----
    NY
    AL
    RI
    TN
    WA
    CA
    CA
    CA
    AZ
    TX
    IN
    MA

    12 sets were returned even though there are only 10 distinct states in the table. California may be a large state, but it's certainly not desirable to count it three times!

    Eliminating duplicates and returning only unique values can be done by using the DISTINCT keyword which follows SELECT.

    SELECT DISTINCT State FROM Clients;

    State
    -----
    NY
    AL
    RI
    TN
    WA
    CA
    AZ
    TX
    IN
    MA

    Now 10 distinct states are returned from the table. DISTINCT has removed the repetitive results and the query returns a set of unique values.

    More Database Articles Articles
    More By bluephoenix

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap