Knowee
Questions
Features
Study Tools

1.Question 1Which of the following queries will return the data for employees who belong to the department with the highest value of department ID.1 pointSELECT * FROM EMPLOYEES WHERE DEPT_ID_DEP = MAX ( SELECT DEPT_ID_DEP FROM DEPARTMENTS )SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS ) SELECT * FROM EMPLOYEES WHERE DEP_ID = MAX(DEP_ID) SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT DEPT_ID_DEP FROM DEPARTMENTS WHERE DEPT_ID_DEP IS MAX )2.Question 2A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?1 pointSELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_IDSELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTSSELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_IDSELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPT_ID_DEP = E.DEP_ID3.Question 3You are writing a query that will give you the total cost to the Pet Rescue organization of rescuing animals. The cost of each rescue is stored in the Cost column. You want the result column to be called “Total_Cost”. Which of the following SQL queries is correct?1 pointSELECT SUM(Cost) FROM PetRescueSELECT SUM(Cost) AS Total_Cost FROM PetRescueSELECT SUM(Total_Cost) From PetRescueSELECT Total_Cost FROM PetRescue4.Question 4Which of the following is the correct syntax for calculating an employee’s age, in YYYY-MM-DD format, with respect to the current date, in MySQL? Assume the date of birth is available as a column ‘DOB’ in the table named ‘Employees’.1 pointSELECT (CURRENT_DATE – DOB) FROM EmployeesSELECT DATEDIFF(CURRENT_DATE, DOB) FROM EmployeesSELECT FROM_DAYS(DATEDIFF(CURRENT_DATE, DOB)) FROM EmployeesSELECT FROM_DAYS(DATE_SUB(CURRENT_DATE, DOB) FROM Employees5.Question 5You have a record of a set of medicines called ‘MEDS’. Their date of expiry is exactly 1 year after their date of manufacturing. The name of the medicines is available as ‘NAME’ and their date of manufacturing is available as a column ‘DOM’. Which of the commands will generate an output that contains name of the medicines and also displays their date of expiry as a column ‘DOE’? Assume use of MySQL.1 pointSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEARS) AS DOE FROM MEDS

Question

1.Question 1Which of the following queries will return the data for employees who belong to the department with the highest value of department ID.1 pointSELECT * FROM EMPLOYEES WHERE DEPT_ID_DEP = MAX ( SELECT DEPT_ID_DEP FROM DEPARTMENTS )SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS ) SELECT * FROM EMPLOYEES WHERE DEP_ID = MAX(DEP_ID) SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT DEPT_ID_DEP FROM DEPARTMENTS WHERE DEPT_ID_DEP IS MAX )2.Question 2A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?1 pointSELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_IDSELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTSSELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_IDSELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPT_ID_DEP = E.DEP_ID3.Question 3You are writing a query that will give you the total cost to the Pet Rescue organization of rescuing animals. The cost of each rescue is stored in the Cost column. You want the result column to be called “Total_Cost”. Which of the following SQL queries is correct?1 pointSELECT SUM(Cost) FROM PetRescueSELECT SUM(Cost) AS Total_Cost FROM PetRescueSELECT SUM(Total_Cost) From PetRescueSELECT Total_Cost FROM PetRescue4.Question 4Which of the following is the correct syntax for calculating an employee’s age, in YYYY-MM-DD format, with respect to the current date, in MySQL? Assume the date of birth is available as a column ‘DOB’ in the table named ‘Employees’.1 pointSELECT (CURRENT_DATE – DOB) FROM EmployeesSELECT DATEDIFF(CURRENT_DATE, DOB) FROM EmployeesSELECT FROM_DAYS(DATEDIFF(CURRENT_DATE, DOB)) FROM EmployeesSELECT FROM_DAYS(DATE_SUB(CURRENT_DATE, DOB) FROM Employees5.Question 5You have a record of a set of medicines called ‘MEDS’. Their date of expiry is exactly 1 year after their date of manufacturing. The name of the medicines is available as ‘NAME’ and their date of manufacturing is available as a column ‘DOM’. Which of the commands will generate an output that contains name of the medicines and also displays their date of expiry as a column ‘DOE’? Assume use of MySQL.1 pointSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEARS) AS DOE FROM MEDS

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

  1. The correct query is: SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS ). This query first finds the maximum department ID from the DEPARTMENTS table and then selects all employees from the EMPLOYEES table where the department ID matches this maximum value.

  2. The correct query is: SELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_ID. This query joins the EMPLOYEES and DEPARTMENTS tables on the department ID and selects the first name from the EMPLOYEES table and the department name from the DEPARTMENTS table.

  3. The correct query is: SELECT SUM(Cost) AS Total_Cost FROM PetRescue. This query sums the cost column from the PetRescue table and aliases the result as Total_Cost.

  4. The correct syntax is: SELECT FROM_DAYS(DATEDIFF(CURRENT_DATE, DOB)) FROM Employees. This syntax calculates the difference in days between the current date and the date of birth, then converts this difference from days to a date format.

  5. The correct command is: SELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDS. This command adds one year to the date of manufacturing to calculate the date of expiry and aliases this result as DOE.

This problem has been solved

Similar Questions

Question 2A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?1 pointSELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPT_ID_DEP = E.DEP_IDSELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_IDSELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_IDSELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTS

Which of the following queries will retrieve the HIGHEST value of SALARY in a table called EMPLOYEES?1 pointSELECT MOST(SALARY) FROM EMPLOYEESSELECT MIN(SALARY) FROM EMPLOYERSELECT MAX(SALARY) FROM EMPLOYEESSELECT SALARY FROM EMPLOYEES WHERE MAX

Evaluate the SQL statement:SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a, (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal;A. The statement gives an error at line 1. B. The statement gives an error at line 6.C. The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all departments that pay less salary than the maximum salary paid in the company.D. The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all employees who earn less than the maximum salary in their department.

Which of the following queries will return the first name of the employee who earns the highest salary?1 pointSELECT FIRST_NAME FROM EMPLOYEES WHERE SALARY IS HIGHESTSELECT FIRST_NAME, MAX(SALARY) FROM EMPLOYEES GROUP BY F_NAMESELECT MAX(SALARY) FROM EMPLOYEESSELECT FIRST_NAME FROM EMPLOYEES WHERE SALARY = ( SELECT MAX(SALARY) FROM EMPLOYEES )

we have following relations:employees(employee_id,first_name,last_name,email,salary,department_id)departments(department_id,department_name,location_id)(1) Find the employees who have the highest salary.(2) Display all the employee name along with department name who are working neitherin ‘HR’ Department nor earns more than 50000.2

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.