Write a query to update the departmentId as "A10" for the details "InformationTechnology" and "E10" for the details "ElectricalElectronicsEngineering" print only the departmentId and details from the department table.
Question
Write a query to update the departmentId as "A10" for the details "InformationTechnology" and "E10" for the details "ElectricalElectronicsEngineering" print only the departmentId and details from the department table.
Solution
Here is the SQL query to update the departmentId as per your requirements:
UPDATE department
SET departmentId = CASE
WHEN details = 'InformationTechnology' THEN 'A10'
WHEN details = 'ElectricalElectronicsEngineering' THEN 'E10'
ELSE departmentId
END;
SELECT departmentId, details FROM department;
This query first updates the departmentId based on the details column. If the details is 'InformationTechnology', it sets the departmentId to 'A10'. If the details is 'ElectricalElectronicsEngineering', it sets the departmentId to 'E10'. If the details is neither of these, it leaves the departmentId as it is.
After the update, it selects and prints the departmentId and details from the department table.
Similar Questions
Write a query to modify the datatype of the column departmentId from VARCHAR(30) to INT in the table 'department'.Refer to the existing table DLL given below:
Problem StatementWrite a query to display the details of employees who are not in the 'Developer' department. Table: EmployeeInput format :The input table is already created, and records are already prepopulated, as mentioned in the problem statement.Output format :The output displays a list of employees who work in departments other than 'Developer' as shown below.id name Department102 Stark HR104 Jack Finance106 Scott AdminRefer to the sample output for the column headers.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Create a package named "dept_package".Declare and define the following 4 Procedures in this package.1) Procedure to insert a new record in the department table. Name : addDepartment Parameters and their types : dept_id department.department_id%type dept_name department.department_name%type dept_block_number department.department_block_number%type 2) Procedure to delete a department when department id is passed as the input parameter. Name : deleteDepartment Parameters and their types : dept_id department.department_id%type 3) Procedure to list the details of all departments (id, name and block number) in ascending order based on id. Name : listDepartment Parameters and their types : It uses cursors dept_details OUT SYS_REFCURSOR 4) Procedure to update a department name (Given the old dept name and new dept name) Name : updateDepartment Parameters and their types : dept_name department.department_name%type new_dept_name department.department_name%type Note:Do not change the package or procedure nameDo not change the argument count and orderDo not change the output text.Instructions:1. Create the package successfully2. Once the package is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PACKAGE query. SubmitSaveExecutePrevious Submission
Problem statementSend feedbackSuppose you have a list of employees in a company, and each employee is represented as an object with the following properties:"id" - a unique identifier for the employee"name" - the employee's name"department" - the department the employee works in"salary" - the employee's current salaryObjectives:You want to make a modification to the list of employees to reflect a recent company-wide salary increase. You have been provided with the following information:Salaries for employees in the "sales" department should be increased by 10%.Salaries for employees in the "engineering" department should be increased by 15%.Salaries for employees in all other departments should be increased by 5%.You need to write a function "increaseSalaries" that takes an array of employee objects and returns a new array of employee objects where each employee's salary has been updated based on their department. The original array of employees should be left unchanged.
Problem StatementWe have created employee and department tables with the below definition without adding foreign key relationTo maintain data integrity in the database, you are required to link the 'departmentId' from the 'department' table with the 'deptId' column in the 'employee' table. This is achieved by establishing a foreign key relationship between the two columns.Write an ALTER query for the 'employee' table to create a foreign key named 'deptIdFk,' referencing 'departmentId' from the 'department' table.Note:Write table name/ column name as given.Input format :The input tables are already prepopulated, as given in the problem statement.Output format :The output should display the detailed description of the employee table.Refer to the sample output for the column headers.Sample test cases :Input 1 :Output 1 :Field Type Null Key Default Extraid int NO PRI NULL name varchar(100) YES NULL address varchar(100) YES NULL age int YES NULL dob date YES NULL deptId int YES MUL NULL
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.