课程: Hands-On SQL Challenges: Test Your Knowledge

Solution: Create invitations for a party

- [Instructor] To solve this challenge, here's what I did. I know I need to get information from the database, and to do that, I'll use the SELECT keyword. Then I need to specify the fields that I want information from, and in this case I'll use FirstName, LastName, and Email. I need to tell the database which table to read information from, so I'll use the FROM keyword and provide the Customers table. Finally, I need to tell the database how to sort the results that we get back. Customers weren't entered into this table in alphabetical order, and the order that records are stored in a database doesn't guarantee that we'll get them back in any particular order anyway, so I'll need to use the ORDER BY keyword and provide a field to use to sort the results. That'll be the LastName field. I'll run this. And there we go. We have a list of customers' names and emails, sorted by the customer's last name.

内容