SOLUTIONS RATED A+
✔✔Subquery - ✔✔- When on SELECT statement is "nested" within another in a format,
it is known as subquery. This is shown when there is a second SELECT phrase within a
set of parenthesis.
✔✔Common DDL commands: - ✔✔- DROP
- ALTER
- RENAME
- CREATE
- TRUNCATE
✔✔Common DML commands: - ✔✔- UPDATE
- DELETE
- INSERT
- MERGE
- SELECT
✔✔Write the basic SQL query command: - ✔✔SELECT<columns>
FROM<table>
WHERE<predicates identifying rows to be included>
✔✔Write the SQL query to "Find the commission percentage and year of hire of
salesperson 186": - ✔✔SELECT COMMPERCT, YEARHIRE
FROM SALESPERSON
WHERE SPNUM=186;
✔✔Write the SQL query to "Retrieve the entire record for salesperson 186": -
✔✔SELECT *
FROM SALESPERSON
WHERE SPNUM=186;
✔✔Write the SQL query to "List the salesperson numbers and salesperson names of
those salespersons who have a commission percentage of 10.": - ✔✔SELECT SPNUM,
SPNAME
FROM SALESPERSON
WHERE COMMPERCT=10;
✔✔Write the SQL query to "List the salesperson numbers, salesperson names, and
commission percentages of the salespersons whose commission percentage is less
than 12.": - ✔✔SELECT SPNUM, SPNAME, COMMPERCT
FROM SALESPERSON
WHERE COMMPERCT<12;
, ✔✔Write the SQL query to "List the customer numbers and headquarters cities of all
customers that have a customer number of at least 1700": - ✔✔SELECT CUSTNUM,
HQCITY
FROM CUSTOMER
WHERE CUSTNUM>=1700;
✔✔Write the SQL query to "List the customer numbers, customer names, and
headquarters cities of the customers that are headquartered in New York and that have
a customer number higher than 1500": - ✔✔SELECT CUSTNUM, CUSTNAME,
HQCITY
FROM CUSTOMER
WHERE HQCITY='New York'
AND CUSTNUM>1500;
✔✔Write the SQL query to "List the customer numbers, customer names, and
headquarters cities of the customers that are headquartered in New York OR that have
customer numbers higher than 1500": - ✔✔SELECT CUSTNUM, CUSTNAME, HQCITY
FROM CUSTOMER
WHERE HQCITY='New York'
OR CUSTNUM>1500;
✔✔Write the SQL query to "List the customers, customer names, and headquarters
cities of the customers that are headquartered in New York or that satisfy the two
conditions of having a customer number higher than 1500 and being headquartered in
Atlanta": - ✔✔SELECT CUSTNUM, CUSTNAME, HQCITY
FROM CUSTOMER
WHERE HQCITY='New York'
OR (CUSTNUM>1500
AND HQCITY='Atlanta');
✔✔Write the SQL query to "List the customer records for those customers whose
names begin with the letter 'A' ": - ✔✔SELECT *
FROM CUSTOMER
WHERE CUSTNAME LIKE 'A%';
✔✔Write the SQL query to "Find the customer numbers, customer names, and
headquarters cities of those customers with the customer numbers greater than 1000.
List the results in alphabetic order by headquarters cities (and have the customer
names within the same city alphabetized)": - ✔✔SELECT CUSTNUM, CUSTNAME,
HQCITY
FROM CUSTOMER
WHERE CUSTNUM>1000
ORDER BY HQCITY, CUSTNAME;