-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_basic_filtering.sql
More file actions
45 lines (37 loc) · 1021 Bytes
/
02_basic_filtering.sql
File metadata and controls
45 lines (37 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- ========================================
-- Day 1: Basic Filtering & WHERE Clause Queries
-- ========================================
-- 1. Find customers from the USA
SELECT *
FROM Customer
WHERE Country = 'USA';
-- 2. Find customers from the USA or Canada
SELECT *
FROM Customer
WHERE Country IN ('USA', 'Canada');
-- 3. Find customers whose first name starts with “A”
SELECT *
FROM Customer
WHERE FirstName LIKE 'A%';
-- 4. Find invoices greater than $10 but less than $20
SELECT *
FROM Invoice
WHERE Total > 10
AND Total < 20
ORDER BY Total;
-- 5. Find invoices billed to Germany
SELECT InvoiceId, BillingCountry, Total
FROM Invoice
WHERE BillingCountry = 'Germany';
-- 6. Find customers with email addresses containing “gmail”
SELECT *
FROM Customer
WHERE Email LIKE '%gmail%';
-- 7. Find customers not from the USA
SELECT CustomerId, FirstName, LastName, Country
FROM Customer
WHERE Country <> 'USA';
-- 8. Find invoices from the year 2025
SELECT *
FROM Invoice
WHERE YEAR(InvoiceDate) = 2025;