-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBasic Queries.sql
More file actions
59 lines (43 loc) · 1.57 KB
/
Copy pathBasic Queries.sql
File metadata and controls
59 lines (43 loc) · 1.57 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
USE [70-761]
--Get all Table Information
SELECT * FROM Person
--Return Everyone with an Email
SELECT * FROM Person
WHERE Email <> 'N/A'
--Return Everyone without an Email
SELECT * FROM Person
WHERE Email = 'N/A'
--Return Everyone over 25ys old
SELECT * FROM Person
WHERE Age > 25
--Return Everyone Between and including 30 and 50 ys old
SELECT * FROM Person
WHERE Age >= 30 and Age <= 50
--Return Names and Phone Number of Everyone Between and including 30 and 50 ys old
SELECT PersonName, Phone FROM Person
WHERE Age BETWEEN 30 AND 50
--Return Names and Ages of Everyone whose name starts with A
SELECT PersonName, Age FROM Person
WHERE PersonName LIKE 'A%'
--Return Names and Ages of Everyone whose name starts with A,J or R
SELECT PersonName, Age FROM Person
WHERE PersonName LIKE '[AJR]%'
--Return Names and Ages of Everyone whose name doesn't start with A,J or R
SELECT PersonName, Age FROM Person
WHERE PersonName LIKE '[^AJR]%'
--Return Names and Ages of Everyone whose name starts with letter between J and R
SELECT PersonName, Age FROM Person
WHERE PersonName LIKE '[J-R]%'
ORDER BY PersonName
--Return Names and Ages of Everyone whose is 18 , 25 40 or 65
SELECT PersonName, Age FROM Person
WHERE Age in (18,25,40,65)
--Return Everyone entered in 2007
SELECT * FROM Person
WHERE YEAR(EntryDate) = '2007'
--Return Everyone entered before 2010
SELECT * FROM Person
WHERE EntryDate < '20100101'
--Return Everyone entered between 2015 and today
SELECT * FROM Person
WHERE EntryDate >= '20150101' AND EntryDate <= GETDATE()