For circumstances where you want your aggregate functions to operate on distinct values, SQL provides the DISTINCT keyword to fold duplicates before aggregation.
- [Instructor] For circumstances … where you want your aggregate functions … to operate on distinct values, … SQL provides the DISTINCT keyword … to be used in aggregate functions. … Let's see how this works. … Here, we're going to use the world database. … And we've seen this query before. … We're just going to count the columns, … or rather the rows, in the country database … that have a value for head of state. … And you see there are 238 rows with a head of state, … and we can look at these values … here and notice something about this: … When we sort this by head of state, … you'll notice that, first of all, … the database is very old and that's okay. … Notice all of the rows that have the same head of state. … Of course, the sun never sets on the British Empire, … or at least, it hadn't at the time … this database was created. … And so you notice a lot of duplicate values. … If you want to just count the distinct values, … you can use a query like this, … where you count distinct head of state. …
This course was created by Bill Weinman. We are pleased to offer this training in our library.
- How databases are organized
- Selecting rows and columns
- Creating new tables
- Inserting and updating data
- 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
- Using CRUD functions
Skill Level Beginner
2. SQL Overview
3. Fundamental Concepts
7. Dates and Times
Dates and times2m 6s
11. Views and Subselects
12. 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.