Homework 3 Code

docx

School

University of Illinois, Urbana Champaign *

*We aren’t endorsed by this school

Course

352

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

3

Uploaded by JudgeClover13366

Report
Jason Prince BADM 352 Assignment 3 Code Excerise 1 EMP Table: 1. select * from EMP where EMP_TITLE = 'MR.' limit 3; 2. select * from EMP order by EMP_NUM; 3. select * from EMP where EMP_DOB = (select max(EMP_DOB) from EMP); select * from EMP where EMP_DOB = (select min(EMP_DOB) from EMP); 4. select * from EMP where EMP_DOB = (select min(EMP_DOB) from EMP) or EMP_DOB = (select max(EMP_DOB) from EMP); 5. select *, year(EMP_HIRE_DATE) from EMP; 6. select *, TIMESTAMPDIFF(year, EMP_DOB, EMP_HIRE_DATE) from EMP; CUSTOMER Table: 7. select * from CUSTOMER order by CUS_LNAME, CUS_FNAME; 8. select * from CUSTOMER where CUS_BALANCE = (select max(CUS_BALANCE) from CUSTOMER); 9. select CUS_AREACODE, count(*) from CUSTOMER group by CUS_AREACODE; PRODUCT Table: 10. select distinct V_CODE from PRODUCT;
11. select * from VENDOR where V_CODE in (select distinct V_CODE from PRODUCT); 12. select * from PRODUCT where P_PRICE in (select max(P_PRICE) from PRODUCT); 13. select count(*) from PRODUCT where P_PRICE < (select avg(P_PRICE) from PRODUCT); INVOICE Table: 14. select CUS_CODE, count(*) from INVOICE group by CUS_CODE; 15. select CUS_CODE, count(*) from INVOICE group by CUS_CODE order by count(*) desc; 16. select count(*), day(INV_DATE) from INVOICE group by day(INV_DATE); 17. select count(*), month(INV_DATE) from INVOICE group by month(INV_DATE); LINE Table: 18. select count(*), INV_NUMBER from LINE group by INV_NUMBER; 19. select count(*), INV_NUMBER from LINE group by INV_NUMBER having count(*)>1; 20. select sum(LINE_UNITS), P_CODE from LINE group by P_CODE order by sum(LINE_UNITS) desc; Exercise 2 1. select * from Country; select * from City; The sheet for city and country language both have a column with the country code. 2. select Name, Population from Country order by Population desc limit 15; 3. select sum(Population) from Country;
4. select Continent, sum(Population) from Country group by Continent; 5. select Continent, sum(Population) from Country group by Continent having sum(Population) > 0 order by sum(Population) desc; 6. select count(*) from Country group by Region; 7. select count(*), CountryCode from City group by CountryCode; 8. select count(*), CountryCode from City group by CountryCode having count(*)>300; 9. select count(*), District from City where CountryCode = (select Code from Country where Name = 'United States') group by District; 10. select count(*), District from City where CountryCode = (select Code from Country where Name = 'United States') group by District having count(Name) > 10; 11. select count(*), District from City where CountryCode = (select Code from Country where Name = 'United States') group by District having count(Name) > 10 order by count(Name) desc; 12. select * from City where ID = (select Capital from Country where Name = 'Brazil'); 13. select count(*), Language from CountryLanguage group by Language order by count(Language) desc;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help