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 the details of the vendors...
Write and run SQL statements to complete the following tasks Show the details of the vendors who are located in area code 615. Show the details of the products that do not have a value for the attribute v_code. Show the details of the invoices whose subtotal is greater than 25 but less than 75. Show the details of the invoice who has the minimum subtotal. Show the codes and names of the vendors who supplied products. Using EXCEPT show...
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...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create SALESREP and CUSTOMER tables Create primary and foreign keys as appropriate. The custNo should use a surrogate key as the primary key with auto-increment increase the balance of the Gonzales account by $100 to a total of $450? Find an average customer balance Display the name of the sales representative and the name of the customer for each customer that has a balance greater...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT