Home arrow BrainDump arrow Page 4 - SQL: Functioning in the Real World

Count Distinct - BrainDump

A couple of months or so ago, I began talking about SQL functions and what they're used for. This article picks up where I left off. It defines the two types of functions, and begins to explain them in great detail.

TABLE OF CONTENTS:
  1. SQL: Functioning in the Real World
  2. What You Talkin Bout Willis?
  3. Count
  4. Count Distinct
  5. Minimum and Maximum
By: James Payne
Rating: starstarstarstarstar / 1
December 10, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Let's step away from the lawsuit scenario for a moment. Let's add a new column to our table called Position. Fill in your database with the added values below.

 

Name

Age

Salary

Position

Ang Ree

92

$12,000

Director

Godzilla Nokamura

45

$50,000

Villain

Mothra Fujiyama

27

$80,000

Villain

King Kong Wong

19

$100,000

Hero

Go-Go Roboto

29

$100,000

Actor created solely for toy sales

If we wanted to know how many unique positions there were (or any other unique items) we could use the Count(Distinct) function. As you can see, there are presently 5 positions in the company. What we want to know though is how many positions there are that don't duplicate themselves.

  Select Count (Distinct Position) from Employees

The result:

  4

This is because the Villain position is a duplicate, and thus one value is not unique.



 
 
>>> More BrainDump Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

BRAINDUMP ARTICLES

- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: