Question

In: Computer Science

Write and run SQL statements to complete the following tasks Show the details of the employees...

Write and run SQL statements to complete the following tasks

  1. Show the details of the employees who are located in area code 901 and their manager employee number is 108.
  2. Show the details of the employees who are also mangers.
  3. Show the details of the customers whose balance is greater than 220 but less than 500.
  4. Show the details of the customers whose balance is highest.
  5. Show customer 10014’s name and the product’s descriptions which he/she purchased and the number of units of each.
  6. List the names of customers and the number of invoices each customer has generated.
  7. Show the codes and names of the customers who have not generated any invoice.
  8. Add a new attribute (column) engaged varchar(3) to the customer table and update the engaged attribute for the customers who have not generated any invoice to ‘No’.

Solutions

Expert Solution

  1. Select employee.* from employee inner join department on employee.Dept_Num = department.Dept_Num where Emp_Phone LIKE '%901%' and department.emp_num = 108;
  2. Select employee.* from employee , department where department.Emp_Num = employee.Emp_Num;
  3. Select * from Customer where Cust_Balance > 220 and Cust_Balance < 500;
  4. Select * from Customer where Cust_Balance = ( Select Max(Cust_Balance) from Customer);
  5. Select Cust_Fname, Cust_Lname, Prod_Descript, Line_Qty from Customer, Invoice, Line, product where Cust_Code = 10014;
  6. Select Cust_Fname, Cust_Lname, Count(Inv_Num) from Customer inner join Invoice on Customer.Cust_Code = Invoice.Cust_Code group by Cust_Fname, Cust_Lname;
  7. Select Customer.Cust_Code, Cust_Fname, Cust_Lname from Customer , Invoice where Customer.Cust_Code != Invoice.Cust_Code ;
  8. Alter Table Customer Add Column engaged varchar(3) ;
  9. Update Customer set engaged = 'No' where Cust_Code NOT IN( Select Cust_Code from Invoice);

Do ask if any doubt.


Related Solutions

Write and run SQL statements to complete the following tasks. Show customer 10014’s name and the...
Write and run SQL statements to complete the following tasks. Show customer 10014’s name and the product’s descriptions which he/she purchased and the number of units of each. Add a new attribute (column) engaged varchar(3) to the customer table and update the engaged attribute for the customers who have not generated any invoice to ‘No’. Task 2 should be completed in two steps i.e. two SQL commands. Sql file -- Creating Tables .headers on .mode column .separator , DROP TABLE...
Create one sql script file to complete the following. You cannot run separate SQL statements for...
Create one sql script file to complete the following. You cannot run separate SQL statements for the homework. You will also need to place a semicolon after each SQL statement, a requirement for SQL files containing multiple SQL statements Lesson 3 Write a query to display the current date. Label the column DATE. Display the last name of all employees who have an A and an E in their last name. For each employee, display the employee number, last_name, salary,...
Can you please explain and show how you would complete the following SQL Injection Attacks tasks...
Can you please explain and show how you would complete the following SQL Injection Attacks tasks using the SEED lab seed Ubuntu 16.04 Virtual Machine: Task 3.1: Modify your own salary. As shown in the Edit Profile page, employees can only update their nicknames, emails, addresses, phone numbers, and passwords; they are not authorized to change their salaries. Assume that you (Alice) are a disgruntled employee, and your boss Boby did not increase your salary this year. You want to...
Write SQL queries for the following statements based on Employees table whose schema is given below:...
Write SQL queries for the following statements based on Employees table whose schema is given below: (Employee_ID,First_Name,Last_Name,Email,Phone_Number,Hire_Date,Job_ID,Salary, Manager_Id, Department_Id) a. Create the given table along with the following constraints: Phone_Number should not be left undefined, salary should be between 10000 and 20000, employee_id should uniquely identify rows and should not be left undefined. User-defined names should be given to constraints. b.  Display each employee’s last name, hire date and salary review date (which is the date after six months of service)....
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2. 10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an SQL statement to display all the information of all Nobel Laureate winners. 2) Write an SQL statement to display the string "Hello, World!". 3) Write an SQL query to display the result of the following expression: 2 * 14 +76. 4) Write an SQL statement to display the winner and category of all Laureate winners. 5) Write an SQL query to find the winner(s)...
Assignment Details: Perform the following tasks: Complete the reading assignment and the interactive lesson before attempting...
Assignment Details: Perform the following tasks: Complete the reading assignment and the interactive lesson before attempting this assignment. Select a recent news article about a life event of an individual. It can be health related, accident related, educational, or even achievement-oriented. It will be one "slice in the lifespan of that person." For example, you might select a story of someone who has achieved a major goal in life after experiencing a debilitating accident. An example would be Nick Vujicic....
In this assignment, you are required to write the SQL statements to answer the following queries...
In this assignment, you are required to write the SQL statements to answer the following queries using PostgreSQL system. The SQL statements comprising the DDL for Henry Books Database are given to you in two files. For that database, answer the following queries. Create the files Q1 to Q10 in PostgreSQL. Do follow the restrictions stated for individual queries. 1. List the title of each book published by Penguin USA. You are allowed to use only 1 table in any...
Please write shell scripts in Kali Linux to complete the following tasks. Task A - Take...
Please write shell scripts in Kali Linux to complete the following tasks. Task A - Take your UIN Write a script like below that reads and displays the MIDAS ID if the following requirements are satisfied: Only lower case letter [a-z] and numeric character[0-9] are allowed MIDAS ID must between 4 to 8 digits Test your script with the following examples: Your MIDAS ID in lower case Your MIDAS ID w.one upper case A string less than 4 digits A...
. Please write the SQL statements required to create the following relations, including appropriate versions of...
. Please write the SQL statements required to create the following relations, including appropriate versions of all primary and foreign key integrity constraints. (10 points) Books (isbn:CHAR(10), title: CHAR(20), author: CHAR(80), qty_in_stock: INTEGER, price: REAL, year_published: INTEGER) Customers (cid:INTEGER, cname: CHAR(80), address: CHAR(200)) Orders (ordernum:INTEGER, cid:INTEGER, order_date: DATE, cardnum:CHAR(16)) Orderlists (ordernum:INTEGER, isbn:CHAR(10), qty:INTEGER, ship_date:DATE)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT