Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions your-code/Challenge_1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
au_id,au_lname,au_fname,title,pub_name
213-46-8915,Green,Marjorie,"The Busy Executive's Database Guide","Algodata Infosystems"
409-56-7008,Bennet,Abraham,"The Busy Executive's Database Guide","Algodata Infosystems"
267-41-2394,O'Leary,Michael,"Cooking with Computers: Surreptitious Balance Sheets","Algodata Infosystems"
724-80-9391,MacFeather,Stearns,"Cooking with Computers: Surreptitious Balance Sheets","Algodata Infosystems"
213-46-8915,Green,Marjorie,"You Can Combat Computer Stress!","New Moon Books"
274-80-9391,Straight,Dean,"Straight Talk About Computers","Algodata Infosystems"
712-45-1867,"del Castillo",Innes,"Silicon Valley Gastronomic Treats","Binnet & Hardley"
722-51-5454,DeFrance,Michel,"The Gourmet Microwave","Binnet & Hardley"
899-46-2035,Ringer,Anne,"The Gourmet Microwave","Binnet & Hardley"
238-95-7766,Carson,Cheryl,"But Is It User Friendly?","Algodata Infosystems"
427-17-2319,Dull,Ann,"Secrets of Silicon Valley","Algodata Infosystems"
846-92-7186,Hunter,Sheryl,"Secrets of Silicon Valley","Algodata Infosystems"
486-29-1786,Locksley,Charlene,"Net Etiquette","Algodata Infosystems"
724-80-9391,MacFeather,Stearns,"Computer Phobic AND Non-Phobic Individuals: Behavior Variations","Binnet & Hardley"
756-30-7391,Karsen,Livia,"Computer Phobic AND Non-Phobic Individuals: Behavior Variations","Binnet & Hardley"
899-46-2035,Ringer,Anne,"Is Anger the Enemy?","New Moon Books"
998-72-3567,Ringer,Albert,"Is Anger the Enemy?","New Moon Books"
998-72-3567,Ringer,Albert,"Life Without Fear","New Moon Books"
172-32-1176,White,Johnson,"Prolonged Data Deprivation: Four Case Studies","New Moon Books"
486-29-1786,Locksley,Charlene,"Emotional Security: A New Algorithm","New Moon Books"
807-91-6654,Panteley,Sylvia,"Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean","Binnet & Hardley"
648-92-1872,Blotchet-Halls,Reginald,"Fifty Years in Buckingham Palace Kitchens","Binnet & Hardley"
267-41-2394,O'Leary,Michael,"Sushi, Anyone?","Binnet & Hardley"
472-27-2349,Gringlesby,Burt,"Sushi, Anyone?","Binnet & Hardley"
672-71-3249,Yokomoto,Akiko,"Sushi, Anyone?","Binnet & Hardley"
26 changes: 26 additions & 0 deletions your-code/UAT_Challenge_1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
au_id,title_id,au_ord,royaltyper
172-32-1176,PS3333,1,100
213-46-8915,BU1032,2,40
213-46-8915,BU2075,1,100
238-95-7766,PC1035,1,100
267-41-2394,BU1111,2,40
267-41-2394,TC7777,2,30
274-80-9391,BU7832,1,100
409-56-7008,BU1032,1,60
427-17-2319,PC8888,1,50
472-27-2349,TC7777,3,30
486-29-1786,PC9999,1,100
486-29-1786,PS7777,1,100
648-92-1872,TC4203,1,100
672-71-3249,TC7777,1,40
712-45-1867,MC2222,1,100
722-51-5454,MC3021,1,75
724-80-9391,BU1111,1,60
724-80-9391,PS1372,2,25
756-30-7391,PS1372,1,75
807-91-6654,TC3218,1,100
846-92-7186,PC8888,2,50
899-46-2035,MC3021,2,25
899-46-2035,PS2091,2,50
998-72-3567,PS2091,1,50
998-72-3567,PS2106,1,100
Binary file added your-code/UAT_OK_CH1.xlsx
Binary file not shown.
68 changes: 68 additions & 0 deletions your-code/solutions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- FIRST STEP : SEE THE TABLES AND THE NAMES OF THE FIELDS:
SELECT * FROM authors;
-- au_id, au_lname, au_fname, phone, address, city, state, zip, contract
SELECT * FROM discounts;
-- discounttype, stor_id, lowqty, highqty, discount
SELECT * FROM employee;
-- emp_id, fname, minit, lname, job_id, job_lvl, pub_id, hire_date
SELECT * from jobs;
-- job_id, job_desc, min_lvl, max_lvl
SELECT * FROM pub_info;
-- pub_id, logo, pr_info
SELECT * FROM publishers;
-- pub_id, pub_name, city, state, country
SELECT * FROM roysched;
-- title_id, lorange, hirange, royalty
SELECT * FROM sales;
-- stor_id, ord_num, ord_date, qty, payterms, title_id
SELECT * FROM stores;
-- stor_id, stor_name, stor_address, city, state, zip
SELECT * FROM titleauthor;
-- au_id, title_id, au_ord, royaltyper
SELECT * FROM titles;
-- title_id, title, type, pub_id, price, advance, royalty, ytd_sales, notes, pubdate

##CHALENGE 1.
-- Select the table in which each required field appear
-- AUTHOR ID: au_id -> authors, titleauthor OK
-- AUTHOR LAST NAME: au_lname -> authors OK
-- AUTHOR FIRST NAME: au_fname -> authors OK
-- TITLE of the published title: title -> titles OK
-- PUBLISHER NAME: pub_name -> publishers
-- *TITLEAUTHOR DIMENSION
SELECT au_id,au_lname,au_fname from authors;
SELECT A.au_id, B.au_lname, B.au_fname from titleauthor A left join authors B on A.au_id = B.au_id;
SELECT A.au_id, A.au_lname, A.au_fname, C.title, D.pub_name from titleauthor B
left join authors A ON A.au_id = B.au_id
left join titles C ON B.title_id = C.title_id
left join publishers D ON C.pub_id = D.pub_id
;

##CHALLENGE 2: INCLUDE TITLE(COUNT) PER AUTH:
SELECT A.au_id, A.au_lname, A.au_fname, D.pub_name,count(C.title_id) AS 'total_titles' from titleauthor B
left join authors A ON A.au_id = B.au_id
left join titles C ON B.title_id = C.title_id
left join publishers D ON C.pub_id = D.pub_id
group by A.au_id, A.au_lname, A.au_fname, D.pub_name
;


##CHALLENGE 3: INCLUDE SOLD_TITLES(sum) PER AUTH - only first 3:
SELECT A.au_id, A.au_lname, A.au_fname, sum(D.qty) AS 'sold_titles' from titleauthor B
left join authors A ON A.au_id = B.au_id
left join titles C ON B.title_id = C.title_id
left join sales D ON C.title_id = D.title_id
group by A.au_id, A.au_lname, A.au_fname
ORDER BY SUM(D.qty) DESC
LIMIT 3;
;

##CHALLENGE 4: INCLUDE SOLD_TITLES(sum) PER AUTH:
SELECT A.au_id, A.au_lname, A.au_fname, sum(D.qty) AS 'sold_titles' from titleauthor B
left join authors A ON A.au_id = B.au_id
INNER join titles C ON B.title_id = C.title_id
INNER join sales D ON C.title_id = D.title_id
group by A.au_id, A.au_lname, A.au_fname
ORDER BY SUM(D.qty) DESC
;