-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClass01sql.sql
More file actions
59 lines (41 loc) · 1.34 KB
/
Class01sql.sql
File metadata and controls
59 lines (41 loc) · 1.34 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
-- clauses:
-- select -> what do you want to retrieve
-- from -> from which table do you want to retrieve
-- where -> to filter the records you want to retrieve
-- 1. retrieve all records from the actor table
select actor_id, first_name, last_name, last_update
from sqlpro.actor;
select *
from sqlpro.actor;
-- 2. retrieve first_name and last_name of all the records from the actor table
select first_name, last_name
from sqlpro.actor;
-- 3. compose a field called full_name which will be
-- concatenation of first_name + ' ' + last_name
-- and retrieve the same for all the records from the actor table
select concat(concat(first_name, ' '), last_name) as full_name
from sqlpro.actor;
-- 4. retieve the first 5 records from the table
select *
from sqlpro.actor
where rownum <= 5;
select *
from sqlpro.actor
where actor_id <= 5;
-- 5. retrieve the records with actor id 2, 4, or 6 from the table
select *
from sqlpro.actor
where actor_id = 2 or actor_id = 4 or actor_id = 6;
select *
from sqlpro.actor
where actor_id in (2, 4, 6);
-- 6. retrieve the records with actor id 6-10 from the table actor
select *
from sqlpro.actor
where actor_id = 6 or actor_id = 7 or actor_id = 8 or actor_id = 9 or actor_id = 10;
select *
from sqlpro.actor
where actor_id in (6, 7, 8, 9, 10);
select *
from sqlpro.actor
where actor_id >= 6 and actor_id <= 10;