WordPress Websites for Engineers: Elevate Your Brand
SQL200.1 Module 1
1. SQL200 Based on SQL Clearly Explained by Jan Harrington SQL Programming Module 1 – Relational Database Background, Basic Single Table Retrieval Operations
30. SELECT with Where Clause Example ( Restriction plus Projection ): Select <column-list> From <table-list> Where <selection-criteria>;
31. SELECT with Where Basic Example ( Restriction plus Projection ): select customer_last_name, customer_street from customers where customer_last_name = “Jones”
39. IN Select * From customers Where customer_last_name in (“Rizzo”, “Jones”, “Garcia”) The list in parentheses can be replaced by a subquery. We will study this later.
41. IS NULL Select * From customers Where customer_street IS NULL SQL uses three valued logic. Must use IS NULL to test for unknowns. A null is NOT the same as blank or empty.
42.
43. BETWEEN Select * From orders Where order_date BETWEEN #1/1/99# and #12/31/99# Note: date formats vary from product to product. Above is Access syntax, SQL Server uses single quotes. Ex: ‘1/1/99’
45. Removing Duplicates Select DISTINCT customer_city From customers List once each city in which there are customers Removes duplicate rows from result set
47. Sorting – ORDER BY DESC will sort in descending order Basic syntax : Select <column list> From <table list> Where <selection criteria> Order by <column list> [DESC]
48. Sorting – ORDER BY Select * From customers Order by customer_state, customer_city Example: List all records sorted by state, city
50. Selecting Top Records Select Top 5 (or top 25 percent) Customer_last_name , contact_zip From customers Order by customer_zip desc ; List largest 5 zips or top 25 % of them…