-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL08Lab.sql
More file actions
65 lines (60 loc) · 1.62 KB
/
SQL08Lab.sql
File metadata and controls
65 lines (60 loc) · 1.62 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
--Jose Guadarrama
--10/30/2014
--1
Select RepTable.SalesRepNo,
RepTable.FirstName,
RepTable.LastName,
RepTable.DeptNo,
DepTable.DeptName
From Guadarrama.SalesRep As RepTable
Join
Guadarrama.Department As DepTable
On RepTable.DeptNo = DepTable.DeptNo
Order By RepTable.SalesRepNo;
--2
Select RepTable.SalesRepNo,
TranTable.TransNo,
TranTable.CustNo,
TranTable.SaleDate,
TranTable.InvoiceAmt
From Guadarrama.SalesRep As RepTable
Join
Guadarrama.SalesTrans As TranTable
On RepTable.SalesRepNo = TranTable.SalesRepNo
Where TranTable.InvoiceAmt <= 1000
Order By RepTable.SalesRepNo;
--3
Select CustTable.CustNo,
CustTable.CustName,
TranTable.InvoiceAmt,
TranTable.ShipDate
From Guadarrama.Customer As CustTable
Join
Guadarrama.SalesTrans As TranTable
On CustTable.CustNo = TranTable.CustNo
Where TranTable.ShipDate Between '2013-10-01' And '2013-10-31'
Order By CustTable.CustNo;
--4
Select TranTable.TransNo,
TranTable.InvoiceAmt,
RepTable.SalesRepNo,
DepTable.DeptName,
CustTable.CustName
From Guadarrama.SalesTrans As TranTable,
Guadarrama.SalesRep As RepTable,
Guadarrama.Department As DepTable,
Guadarrama.Customer As CustTable
Where RepTable.SalesRepNo = TranTable.SalesRepNo And
TranTable.CustNo = CustTable.CustNo And
RepTable.DeptNo = DepTable.DeptNo And
TranTable.InvoiceAmt = 1000;
--5
Select SalesRep.SalesRepNo,
SalesRep.LastName,
SalesTrans.TransNo,
SalesTrans.SalesRepNo,
SalesTrans.InvoiceAmt
From Guadarrama.SalesRep
Left Exception Join
Guadarrama.SalesTrans
On SalesRep.SalesRepNo = SalesTrans.SalesRepNo;