SQL thru DB on Server BPA CSUB Yong
SQL thru DB on Server BPA CSUB Yong Choi
SQL 1 Select all records where the Customer. ID column has the value 32. SELECT * FROM Customers WHERE Customer. ID = 32;
SQL 2 Select all records where the City column has the value 'Berlin' and the Postal. Code column has the value 12209. SELECT * FROM Customers WHERE City = 'Berlin' AND Postal. Code = 12209;
SQL 3 Select all records where the City column has the value 'Berlin' or 'London'. SELECT * FROM Customers WHERE City = 'Berlin'OR City = 'London';
SQL 4 Select all records from the Customers table, sort the result alphabetically by City. SELECT * FROM Customers ORDER BY City;
SQL 5 Select all records from the Customers table, sort the result reversed alphabetically by the column City. SELECT * FROM Customers ORDER BY City DESC;
SQL 6 Select all records where the first letter of the City is an "s". SELECT * FROM Customers WHERE City LIKE 'a%';
SQL 7 Select all records where the first letter of the City is an "a" or a "c" or an "s". SELECT * FROM Customers WHERE City LIKE '[acs]%';
SQL 8 List the number of customers in each country. SELECT COUNT(Customer. ID), Country FROM Customers GROUP BY Country;
SQL 9 List the number of customers in each country, ordered by the country with the most customers first. SELECT COUNT(Customer. ID), Country FROM Customers GROUP BY Country ORDER BY COUNT(Customer. ID) DESC;
- Slides: 10