For circumstances where you want your aggregate functions to operate on distinct values, learn how SQL provides the DISTINCT keyword to fold duplicates before aggregation.
- [Instructor] For circumstances…where you want your aggregate function…to operate on distinct values,…SQL allows the distinct keyword to be used…in aggregate functions.…Let's see how this works.…Go ahead and select the world database for this.…And now if I were to count…the head of state column in the country database,…you notice that we get a value of 238,…which means that there's 238 non-null values…in the head of state column.…
This is not really counting the heads of state,…it's counting the rows that have a value…in the head of state column.…If you just look at the column,…and I'll…take the count function out and we'll order it…by head of state.…You notice something interesting here.…That some of these heads of state…are head of state of many countries.…You'll also notice that the database is very old,…and that's fine, for our purposes.…
But if we go back to our count,…we can count head of state…but we can count just the distinct values,…not all of the values.…So if I say distinct...…Now we get 179.…This is very different than the 238 we had before.…
- Understanding SQL terminology and syntax
- Creating new tables
- Inserting and updating data
- Writing basic SQL queries
- Sorting and filtering
- Accessing related tables with JOIN
- Working with strings
- Understanding numeric types
- Using aggregate functions and transactions
- Automating data with triggers
- Creating views
- Defining functions in PHP
Skill Level Beginner
2. SQL Overview
3. Fundamental Concepts
7. Dates and Times
Dates and times1m 52s
11. Views and Subselects
12. Defined Functions
13. A Simple CRUD Application
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.