Introduction to Oracle SQL
Sara Billen
Curriculum Manager

SELECT FirstName, LastName, Country
FROM Customer
WHERE Country = 'Portugal'
| FirstName | LastName | Country |
|-----------|-----------|----------|
| João | Fernandes | Portugal |
| Madalena | Sampaio | Portugal |
| Operator | Description |
|---|---|
| > | Greater than |
| >= | Greater than or equal to |
| < | Less than |
| <= | Less than or equal to |
| = | Equal |
| <> | Not equal |
SELECT UnitPrice
FROM Track
WHERE UnitPrice <> 0.99

SELECT Name, Milliseconds
FROM Track
WHERE Milliseconds BETWEEN 100000 AND 200000
| Name | Milliseconds |
|-------------------|--------------|
| Perfect | 188133 |
| Right Through You | 176117 |
| We Die Young | 152084 |
| Put You Down | 196231 |
| ... |
SELECT EmployeeId, LastName, Title
FROM Employee
WHERE EmployeeId IN (4, 5, 6)
| EmployeeId | LastName | Title |
|------------|----------|---------------------|
| 4 | Park | Sales Support Agent |
| 5 | Johnson | Sales Support Agent |
| 6 | Mitchell | IT Manager |
Select rows that match a character pattern by using LIKE
| Symbol | Description |
|---|---|
% |
Represents any sequence of zero or more characters |
_ |
Represents any single character |
SELECT LastName
FROM Employee
WHERE LastName LIKE '_a%'
| LastName |
|----------|
| Park |
| Callahan |

SELECT InvoiceId, BillingCountry, Total
FROM Invoice
WHERE BillingCountry = 'Australia'
AND Total > 4
| InvoiceId | BillingCountry | Total |
|-----------|----------------|-------|
| 66 | Australia | 5.94 |
| 250 | Australia | 13.86 |
| 305 | Australia | 8.91 |
SELECT InvoiceId, BillingCountry, Total
FROM Invoice
WHERE BillingCountry = 'Australia'
OR Total > 4
| InvoiceId | BillingCountry | Total |
|-----------|----------------|-------|
| 3 | Belgium | 5.94 |
| 4 | Canada | 8.91 |
| 5 | USA | 13.86 |
| 10 | Ireland | 5.94 |
| ... |
SELECT InvoiceId, BillingCountry, Total
FROM Invoice
WHERE BillingCountry NOT IN ('Australia', 'Canada', 'United Kingdom')
| InvoiceId | BillingCountry | Total |
|-----------|----------------|-------|
| 1 | Germany | 1.98 |
| 2 | Norway | 3.96 |
| 3 | Belgium | 5.94 |
| 5 | USA | 13.86 |
| ... |
WHERE: filter rows based on a condition
=, <, >, <=, >=, <>BETWEEN, IN, LIKEAND, OR, NOTIntroduction to Oracle SQL