
Concept explainers
What's wrong with my SQL code? It doesn't run. The SQL files are in the images attached. Queries should extract the answers directly.
Use TopBabyNamesbyState.csv1 and write queries to extract the following information:
# Which name in which state and in which year had the highest number of occurrences. #
SELECT TopName, state, year from TopBabyNamesbyState
where occurences=(select max(occurrences) from TopBabyNamesbyState);
# What is the average occurrence of “Jessica” as a top name in the state of CA? #
SELECT avg(occurrences)
FROM TopBabyNamesbyState
WHERE TopName='Jessica' and state='CA'
Group by occurrences, state;
# The three most popular female names in WA state since 2000. Popularity is based on the total number of occurrences. Report the names along with the total number of occurrences. #
SELECT topname AS Name, Occurrence
FROM TopBabyNamesbyState where year>=2000 and state='WA' and gender='F'
ORDER BY
Occurrence DESC
limit 3;
# Make a list of names that have an average occurrence greater than 1000. Order the result table by name in an ascending alphabetical order. #
SELECT topname AS Name, avg(Occurrence)
FROM TopBabyNamesbyState
Group by topname
having avg(Occurrence)>1000
order by topname ASC;



Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Query 3: Write a parameter query to display the names of all prospects each member tried to recruit based on the member’s first name and the member’s last name you input. List the member’s First Name, member’s Last Name, prospect’s First Name, and prospect’s Last Name (in this order in the query grid). Display the member’s First Name Heading as Member First Name, member’s Last Name Heading as Member Last Name, prospect’s first name heading as Prospect First Name, and prospect’s last name heading as Prospect Last Name. Sort the list by Member Last Name, Member First Name, Prospect Last Name, and Prospect First Name, all ascending order. (WE ARE USING ACCESS SO I AM JUST TRYING TO UNDERSTAND WHAT TO PUT AND PLUG IN ETC. USE MY PICTURES AS REFERRENCE!)arrow_forwardTask 1: The Finance team wants to calculate a VAT (8%) on the amount of the stay reservations in the database. However, the team wants to calculate the VAT after the discounts are applied on the prices. In addition, it is important to remember if there is no discount/offers, then the value is NULL in the TRAVELS table. Create a procedure called VATCalculator to calculate the VAT amount and return with the corresponding travel ID. In addition, execute the procedure to account for NULL values and send the respective result to the team. The VAT value should be rounded to 2 decimals. Create a procedure to calculate the VAT. 1 Make sure you are using the following format to change the delimiter for the procedure: DELIMITER $$-- statements --END $$DELIMITER ; Test QueryCALL VATCalculator() Expected Results TRAVEL_ID VAT 5001 1.24 5002 1.64 5003 0.99 5004 2.12 5005 0.89 5006 1.05 5007 0.30 5008 1.51 5009 1.08 5010 1.64arrow_forwardWhat's wrong with my SQL code? It doesn't run. The SQL files are in the images attached. Queries should extract the answers directly. Use Employee.sql and Office.sql and write queries to extract the following information: # Retrieve all information about employees whose hired date is 31 and whose last name consists of exactly five characters. #SELECT * from employees where to_char(hired_date, 'DD') =31 and length(LastName)=5; # Make a list of all employees who have a salary more than the average salary of all employees. #SELECT AVG(salaries) FROM employeesSELECT * FROM employees WHERE salary > ALL(SELECT avg(salary)FROM employee); # How many female employees have a salary higher than the average salary of all employees? #SELECT COUNT FROM employees WHERE salary > ALL(SELECT avg(salary) FROM employees )AND Gender='Female';arrow_forward
- i amm trying to do some work in sql developer insert data from nametest to names i want only to insert year ,name and gender ,then create a id for each data in the databse . what commend shouldi use ? i try "INSERT INTO names(Year, Name, gender),SELECT (Year_, name_, genderA) FROM namestest; it shows Error starting at line : 1 in command -INSERT INTO names(Year, Name, gender),SELECT (Year_, name_, genderA) FROM namestestError at Command Line : 2 Column : 21Error report -SQL Error: ORA-00926: missing VALUES keyword00926. 00000 - "missing VALUES keyword"*Cause: how to make it corrrect ?and make a "id "for each data ?arrow_forwardThe Finance team wants to calculate a VAT (8%) on the amount of the stay reservations in the database. However, the team wants to calculate the VAT after the discounts are applied on the prices. In addition, it is important to remember if there is no discount/offers, then the value is NULL in the TRAVELS table. Create a procedure called VATCalculator to calculate the VAT amount and return with the corresponding travel ID. In addition, execute the procedure to account for NULL values and send the respective result to the team. The VAT value should be rounded to 2 decimals.arrow_forwardWrite a stored procedure named updateUnitsOnOrder(). The updateUnitsOnOrder ()procedure should update the UnitsOnOrder field of those products that are discontinued. It should set the UnitsOnOrder field to 99 for those discontinued products. Hint: There is no need to use cursor processing for this stored procedure.arrow_forward
- Go to the w3schools website’s SQL browser IDE. This is where you canwrite and test your SQL code using their databases. Once you are happywith it, paste your code in a text file named Student.txt and save it in yourtask folder.● Write the SQL code to create a table called Student. The table structure issummarised in the table below (Note that STU_NUM is the primary key):Attribute Name Data TypeSTU_NUM CHAR(6)STU_SNAME VARCHAR(15)STU_FNAME VARCHAR(15)STU_INITIAL CHAR(1)STU_STARTDATE DATECOURSE_CODE CHAR(3)PROJ_NUM INT(2)● After you have created the table in question 1, write the SQL code to enterthe first two rows of the table as below:STU_NUMSTU_SNAMESTU_FNAMESTU_INITIALSTU_STARTDATECOURSE_CODEPROJ_NUM01 Snow John E 05-Apr-14 201 602 Stark Arya C 12-Jul-17 305 11● Assuming all the data in the Student table has been entered as shownbelow, write the SQL code that will list all attributes for a COURSE_CODE of305.…arrow_forwardthis oracle code have some error , how to fix it ? this is the sql code .and it have error . CREATE or replace PROCEDURE CONVERT_VAL(&v1 varchar2(2), &v2 varchar2(2), &amt number)asval varchar(100);val1 varchar(2):= ':v1';val2 varchar(2):=':v2';amount number:= :amt;BeginSelect case when val1!=val2 then case when lower(val1)='km' and lower(val2) = 'cm' then amount||lower(val1) ||amount*100000||' '||lower(val2) when lower(val1)='km' and lower(val2) = 'mt' then amount||lower(val1) ||amount*1000||' '||lower(val2) when lower(val1)='km' and lower(val2) = 'mm' then amount||lower(val1) ||amount*1000000||' '||lower(val2) when lower(val1)='cm' and lower(val2) = 'km'…arrow_forwardCan someone help me make SQL code for theses 5 queries? All records where City begins with "B". CustomerName in Denmark. All records where PostalCode is greater than "99999". All records where ContactName starts with "P" and Country ends with "k". The ContactName and Address where Country starts with 'G'arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





