2. The Basics of SQL for Analytics
Activity 3: Querying the customers Table Using Basic Keywords in a SELECT Query
Solution
- Open your favorite SQL client and connect to the
sqlda
database. Examine the schema for thecustomers
table from the schema dropdown. Notice the names of the columns, the same as we did in Exercise 6, Querying Salespeople, for thesalespeople
table. - Execute the following query to fetch customers in the state of Florida in alphabetical order:
SELECT email FROM customers WHERE state='FL' ORDER BY email
The following is the output of the preceding code:
Figure 2.13: Emails of customers from Florida in alphabetical order
- Execute the following query to pull all the first names, last names, and email addresses for ZoomZoom customers in New York City in the state of New York. The customers would be ordered alphabetically by the last name followed by the first name:
SELECT first_name, last_name, email FROM customers WHERE city='New York City...