-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.sql
More file actions
60 lines (49 loc) · 797 Bytes
/
demo.sql
File metadata and controls
60 lines (49 loc) · 797 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# price list with discount
select
title_name,
price as "List Price",
round (price*.10,2) as "You Saved",
round (price*.90,2) as "Sales Price"
from
titles;
# add fname and lname
select
concat(au_fname," ", au_lname)
from
authors;
# only 415 area codes
select
au_lname,
phone
from
authors
where
substr(phone from 1 for 3)='415';
# capitalize
select
au_lname,
upper(au_lname),
lower(au_lname)
from
authors;
# trim, takes away all white space
select
trim(au_lname),
character_length(trim(au_lname)),
character_length(au_lname)
from
authors;
# dates
select
title_id,
extract(year from pubdate) as "Year"
from
titles
where
extract(year from pubdate) between 2001 and 2002;
select
title_id,
title_name,
pubdate + interval 26 year as "Copyright Expire"
from
titles;