SQL Queries for Database Management

Slide Note
Embed
Share

Explore a series of SQL queries for efficient database management, including selecting specific records, sorting data, and counting customers by country. Enhance your SQL skills with these practical examples showcasing various query types and techniques.


Uploaded on Jul 19, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. SQL thru DB on Server BPA CSUB Yong Choi

  2. SQL 1 Select all records where the CustomerID column has the value 32. SELECT * FROM Customers WHERE CustomerID = 32;

  3. SQL 2 Select all records where the City column has the value 'Berlin' and the PostalCode column has the value 12209. SELECT * FROM Customers WHERE City = 'Berlin' AND PostalCode = 12209;

  4. SQL 3 Select all records where the City column has the value 'Berlin' or 'London'. SELECT * FROM Customers WHERE City = 'Berlin'OR City = 'London';

  5. SQL 4 Select all records from the Customers table, sort the result alphabetically by City. SELECT * FROM Customers ORDER BY City;

  6. 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;

  7. SQL 6 Select all records where the first letter of the City is an "s". SELECT * FROM Customers WHERE City LIKE 'a%';

  8. 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]%';

  9. SQL 8 List the number of customers in each country. SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country;

  10. SQL 9 List the number of customers in each country, ordered by the country with the most customers first. SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country ORDER BY COUNT(CustomerID) DESC;

Related


More Related Content