-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathORACLE_Exercise 6.txt
More file actions
92 lines (72 loc) · 4.01 KB
/
ORACLE_Exercise 6.txt
File metadata and controls
92 lines (72 loc) · 4.01 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
1) Write two different queries that would produce all orders taken on October 3rd or 4th, 1990.
SELECT * FROM ORDERS
2 WHERE (ODATE='03-OCT-1990' OR ODATE='04-OCT-1990');
ONUM AMT ODATE CNUM SNUM
---------- ---------- --------- ---------- ----------
3001 18.69 03-OCT-90 2008 1007
3003 767.19 03-OCT-90 2001 1001
3002 1900.1 03-OCT-90 2007 1004
3005 5160.45 03-OCT-90 2003 1002
3006 1098.16 03-OCT-90 2008 1007
3009 1713.23 04-OCT-90 2002 1003
3007 75.75 04-OCT-90 2004 1002
7 rows selected.
SELECT * FROM ORDERS
2 WHERE ODATE < '05-OCT-1990';
ONUM AMT ODATE CNUM SNUM
---------- ---------- --------- ---------- ----------
3001 18.69 03-OCT-90 2008 1007
3003 767.19 03-OCT-90 2001 1001
3002 1900.1 03-OCT-90 2007 1004
3005 5160.45 03-OCT-90 2003 1002
3006 1098.16 03-OCT-90 2008 1007
3009 1713.23 04-OCT-90 2002 1003
3007 75.75 04-OCT-90 2004 1002
7 rows selected.
=================================================================================================================
2) Write a query that selects all of the customers serviced by Peel or Motika.
(Hint: the snum field relates the two tables to one another).
SELECT * FROM CUSTOMERS
2 WHERE SNUM=1001 OR SNUM=1004;
CNUM CNAME CITY RATING SNUM
---------- ---------- ---------- ---------- ----------
2001 HOFFMAN LONDON 100 1001
2005 CLEMENS LONDON 100 1001
2007 PEREIRA ROME 100 1004
==================================================================================================================
3) Write a query that will produce all the customers whose names begin with a letter from ‘A’ to ‘G’.
SELECT * FROM CUSTOMERS
2 WHERE CNAME>='A' AND CNAME<'H'
3 ORDER BY CNAME;
CNUM CNAME CITY RATING SNUM
---------- ---------- ---------- ---------- ----------
2006 CISNEROS SAN JOSE 300 1007
2005 CLEMENS LONDON 100 1001
2002 GIOVANNI ROME 200 1003
2004 GRASS BERLIN 300 1002
====================================================================================================================
4) Write a query that selects all customers whose names begin with the letter ‘C’.
SELECT * FROM CUSTOMERS
2 WHERE CNAME LIKE 'C%';
CNUM CNAME CITY RATING SNUM
---------- ---------- ---------- ---------- ----------
2005 CLEMENS LONDON 100 1001
2006 CISNEROS SAN JOSE 300 1007
====================================================================================================================
5) Write a query that selects all orders except those with zeroes or NULLs in the amt field.
SELECT * FROM ORDERS
2 WHERE AMT IS NOT NULL AND AMT>0;
ONUM AMT ODATE CNUM SNUM
---------- ---------- --------- ---------- ----------
3001 18.69 03-OCT-90 2008 1007
3003 767.19 03-OCT-90 2001 1001
3002 1900.1 03-OCT-90 2007 1004
3005 5160.45 03-OCT-90 2003 1002
3006 1098.16 03-OCT-90 2008 1007
3009 1713.23 04-OCT-90 2002 1003
3007 75.75 04-OCT-90 2004 1002
3008 4723 05-OCT-90 2006 1001
3010 1309.95 06-OCT-90 2004 1002
3011 9891.88 06-OCT-90 2006 1001
10 rows selected.
====================================================================================================================