Initial Commit
This commit is contained in:
65
Labs/Lab5/AllQueries.txt
Normal file
65
Labs/Lab5/AllQueries.txt
Normal file
@ -0,0 +1,65 @@
|
||||
1:
|
||||
select *
|
||||
from LGBRAND
|
||||
order by BRAND_TYPE;
|
||||
2:
|
||||
select BRAND_TYPE as `Brand Type` ,count(BRAND_TYPE) as `Number of each brand types`
|
||||
from LGBRAND
|
||||
group by BRAND_TYPE;
|
||||
3:
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where CUST_BALANCE != 0
|
||||
group by CUST_STATE;
|
||||
4:
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100;
|
||||
5:
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100
|
||||
order by STATE desc;
|
||||
6:
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100
|
||||
order by count(CUST_CODE);
|
||||
7:
|
||||
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`
|
||||
from LGCUSTOMER
|
||||
natural join LGINVOICE
|
||||
natural join LGLINE
|
||||
natural join LGPRODUCT
|
||||
natural join LGBRAND
|
||||
where
|
||||
CUST_STATE = "ME"
|
||||
group by BRAND_TYPE;
|
||||
8:
|
||||
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`, CUST_STATE as `State`
|
||||
from LGCUSTOMER
|
||||
natural join LGINVOICE
|
||||
natural join LGLINE
|
||||
natural join LGPRODUCT
|
||||
natural join LGBRAND
|
||||
group by BRAND_TYPE, CUST_STATE
|
||||
having SUM(LINE_NUM) < 10;
|
||||
9:
|
||||
select
|
||||
MAX(EMP_HIREDATE) as `Hire date`,
|
||||
EMP_FNAME as `First Name`,
|
||||
EMP_LNAME as `Last Name`,
|
||||
DATEDIFF(CURRENT_DATE, MAX(EMP_HIREDATE)) as `Days since hire`
|
||||
from LGEMPLOYEE;
|
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.docx
Normal file
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.docx
Normal file
Binary file not shown.
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.pdf
Normal file
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.pdf
Normal file
Binary file not shown.
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.zip
Normal file
BIN
Labs/Lab5/IsaacShoebottom_CS1103_Lab5.zip
Normal file
Binary file not shown.
BIN
Labs/Lab5/Lab5 - Complex Queries.pdf
Normal file
BIN
Labs/Lab5/Lab5 - Complex Queries.pdf
Normal file
Binary file not shown.
BIN
Labs/Lab5/Lab5.zip
Normal file
BIN
Labs/Lab5/Lab5.zip
Normal file
Binary file not shown.
3
Labs/Lab5/Q1.sql
Normal file
3
Labs/Lab5/Q1.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select *
|
||||
from LGBRAND
|
||||
order by BRAND_TYPE;
|
17
Labs/Lab5/Q1.txt
Normal file
17
Labs/Lab5/Q1.txt
Normal file
@ -0,0 +1,17 @@
|
||||
+----------+--------------------+------------+
|
||||
| BRAND_ID | BRAND_NAME | BRAND_TYPE |
|
||||
+----------+--------------------+------------+
|
||||
| 25 | STUTTENFURST | CONTRACTOR |
|
||||
| 27 | HOME COMFORT | CONTRACTOR |
|
||||
| 28 | OLDE TYME QUALITY | CONTRACTOR |
|
||||
| 30 | LONG HAUL | CONTRACTOR |
|
||||
| 35 | LE MODE | PREMIUM |
|
||||
| 26 | HOMESTEADER FINEST | PREMIUM |
|
||||
| 33 | BINDER PRIME | PREMIUM |
|
||||
| 34 | PRIME OF LIFE | VALUE |
|
||||
| 32 | YOUR HOME HELPER | VALUE |
|
||||
| 31 | VALU-MATTE | VALUE |
|
||||
| 29 | BUSTERS | VALUE |
|
||||
| 24 | REGAL HOME | VALUE |
|
||||
| 23 | FORESTERS BEST | VALUE |
|
||||
+----------+--------------------+------------+
|
3
Labs/Lab5/Q2.sql
Normal file
3
Labs/Lab5/Q2.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select BRAND_TYPE as `Brand Type` ,count(BRAND_TYPE) as `Number of each brand types`
|
||||
from LGBRAND
|
||||
group by BRAND_TYPE;
|
7
Labs/Lab5/Q2.txt
Normal file
7
Labs/Lab5/Q2.txt
Normal file
@ -0,0 +1,7 @@
|
||||
+------------+----------------------------+
|
||||
| Brand Type | Number of each brand types |
|
||||
+------------+----------------------------+
|
||||
| CONTRACTOR | 4 |
|
||||
| PREMIUM | 3 |
|
||||
| VALUE | 6 |
|
||||
+------------+----------------------------+
|
4
Labs/Lab5/Q3.sql
Normal file
4
Labs/Lab5/Q3.sql
Normal file
@ -0,0 +1,4 @@
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where CUST_BALANCE != 0
|
||||
group by CUST_STATE;
|
28
Labs/Lab5/Q3.txt
Normal file
28
Labs/Lab5/Q3.txt
Normal file
@ -0,0 +1,28 @@
|
||||
+-------+-----------------------------+
|
||||
| State | Number of non zero balances |
|
||||
+-------+-----------------------------+
|
||||
| AL | 39 |
|
||||
| CT | 12 |
|
||||
| DE | 2 |
|
||||
| FL | 57 |
|
||||
| GA | 32 |
|
||||
| IN | 52 |
|
||||
| KY | 42 |
|
||||
| MA | 34 |
|
||||
| MD | 51 |
|
||||
| ME | 14 |
|
||||
| MI | 30 |
|
||||
| MS | 24 |
|
||||
| NC | 59 |
|
||||
| NH | 8 |
|
||||
| NJ | 34 |
|
||||
| NY | 104 |
|
||||
| OH | 60 |
|
||||
| PA | 118 |
|
||||
| RI | 8 |
|
||||
| SC | 23 |
|
||||
| TN | 32 |
|
||||
| VA | 38 |
|
||||
| VT | 27 |
|
||||
| WV | 27 |
|
||||
+-------+-----------------------------+
|
7
Labs/Lab5/Q4.sql
Normal file
7
Labs/Lab5/Q4.sql
Normal file
@ -0,0 +1,7 @@
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100;
|
6
Labs/Lab5/Q4.txt
Normal file
6
Labs/Lab5/Q4.txt
Normal file
@ -0,0 +1,6 @@
|
||||
+-------+-----------------------------+
|
||||
| State | Number of non zero balances |
|
||||
+-------+-----------------------------+
|
||||
| NY | 104 |
|
||||
| PA | 118 |
|
||||
+-------+-----------------------------+
|
8
Labs/Lab5/Q5.sql
Normal file
8
Labs/Lab5/Q5.sql
Normal file
@ -0,0 +1,8 @@
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100
|
||||
order by STATE desc;
|
7
Labs/Lab5/Q5.txt
Normal file
7
Labs/Lab5/Q5.txt
Normal file
@ -0,0 +1,7 @@
|
||||
+-------+-----------------------------+
|
||||
| State | Number of non zero balances |
|
||||
+-------+-----------------------------+
|
||||
| PA | 118 |
|
||||
| NY | 104 |
|
||||
+-------+-----------------------------+
|
||||
|
8
Labs/Lab5/Q6.sql
Normal file
8
Labs/Lab5/Q6.sql
Normal file
@ -0,0 +1,8 @@
|
||||
select CUST_STATE as `State`, count(CUST_BALANCE) as `Number of non zero balances`
|
||||
from LGCUSTOMER
|
||||
where
|
||||
CUST_BALANCE != 0
|
||||
group by CUST_STATE
|
||||
having
|
||||
count(CUST_CODE) > 100
|
||||
order by count(CUST_CODE);
|
7
Labs/Lab5/Q6.txt
Normal file
7
Labs/Lab5/Q6.txt
Normal file
@ -0,0 +1,7 @@
|
||||
+-------+-----------------------------+
|
||||
| State | Number of non zero balances |
|
||||
+-------+-----------------------------+
|
||||
| NY | 104 |
|
||||
| PA | 118 |
|
||||
+-------+-----------------------------+
|
||||
|
9
Labs/Lab5/Q7.sql
Normal file
9
Labs/Lab5/Q7.sql
Normal file
@ -0,0 +1,9 @@
|
||||
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`
|
||||
from LGCUSTOMER
|
||||
natural join LGINVOICE
|
||||
natural join LGLINE
|
||||
natural join LGPRODUCT
|
||||
natural join LGBRAND
|
||||
where
|
||||
CUST_STATE = "ME"
|
||||
group by BRAND_TYPE;
|
8
Labs/Lab5/Q7.txt
Normal file
8
Labs/Lab5/Q7.txt
Normal file
@ -0,0 +1,8 @@
|
||||
+------------------------------+------------+
|
||||
| Number of Products purchased | Brand |
|
||||
+------------------------------+------------+
|
||||
| 249 | CONTRACTOR |
|
||||
| 126 | PREMIUM |
|
||||
| 130 | VALUE |
|
||||
+------------------------------+------------+
|
||||
|
8
Labs/Lab5/Q8.sql
Normal file
8
Labs/Lab5/Q8.sql
Normal file
@ -0,0 +1,8 @@
|
||||
select SUM(LINE_NUM) as `Number of Products purchased`, BRAND_TYPE as `Brand`, CUST_STATE as `State`
|
||||
from LGCUSTOMER
|
||||
natural join LGINVOICE
|
||||
natural join LGLINE
|
||||
natural join LGPRODUCT
|
||||
natural join LGBRAND
|
||||
group by BRAND_TYPE, CUST_STATE
|
||||
having SUM(LINE_NUM) < 10;
|
6
Labs/Lab5/Q8.txt
Normal file
6
Labs/Lab5/Q8.txt
Normal file
@ -0,0 +1,6 @@
|
||||
+------------------------------+-------+-------+
|
||||
| Number of Products purchased | Brand | State |
|
||||
+------------------------------+-------+-------+
|
||||
| 7 | VALUE | DE |
|
||||
+------------------------------+-------+-------+
|
||||
|
6
Labs/Lab5/Q9.sql
Normal file
6
Labs/Lab5/Q9.sql
Normal file
@ -0,0 +1,6 @@
|
||||
select
|
||||
MAX(EMP_HIREDATE) as `Hire date`,
|
||||
EMP_FNAME as `First Name`,
|
||||
EMP_LNAME as `Last Name`,
|
||||
DATEDIFF(CURRENT_DATE, MAX(EMP_HIREDATE)) as `Days since hire`
|
||||
from LGEMPLOYEE;
|
6
Labs/Lab5/Q9.txt
Normal file
6
Labs/Lab5/Q9.txt
Normal file
@ -0,0 +1,6 @@
|
||||
+------------+------------+-----------+-----------------+
|
||||
| Hire date | First Name | Last Name | Days since hire |
|
||||
+------------+------------+-----------+-----------------+
|
||||
| 2017-12-15 | TAMARA | MCDONALD | 1155 |
|
||||
+------------+------------+-----------+-----------------+
|
||||
|
Reference in New Issue
Block a user