Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Distinct

September 13, 1998

It will often be the case that several rows will contain duplicate data in a specified column and that you will only want to view one to represent the group. For example, suppose you wanted to find out which employees had made sales in the SALES table.

If you were to use:

    SELECT E_NUM
    FROM SALES;

you would get:

    E_NUM
    ------
    101
    102
    101
    ------

In this case, Employee number 101 has been reported twice even though once is enough. In this case, you would use the DISTINCT operator to filter out duplicates.

    SELECT DISTINCT E_NUM
    FROM SALES;

You would get:

    E_NUM
    ------
    101
    102
    ------

Another common usage of distinct is to use it with a COUNT such as:

    SELECT num_successful_salesmen  = 
           COUNT (DISTINCT E_NUM)
    FROM SALES;

which would produce:

    num_successful_salesmen
    ------
    2
    ------

Counting Records
Introduction to Databases for the Web | Table of Contents
Averages


Up to => Home / Authoring / DB / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers