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...
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....
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)
Write a program to complete the following tasks. Record all results to a data file called "GradeSheet.dat".
 c++Write a program to complete the following tasks. Record all results to a data file called "GradeSheet.dat".(1) Read the grade sheet from attached data file, "Assignment4.dat". Print the original grade sheet.(3) Write a module to sort array GRADE[] and print the sorted grade sheet.(4) Write a module to sort array NAME[] and print the sorted grade sheet.(5) Write a module to sort array ID[] and print the sorted grade sheet.(6) Write a module to print the student's id, name, and...
Write and run the SQL to list the different expected graduation dates [class of 20XX] in...
Write and run the SQL to list the different expected graduation dates [class of 20XX] in the BSU_Students table. List each expected graduation date only once.  
Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in...
Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in the WPC Database in MySQL: Display all records from the Employee table for employees working in the “Marketing” department. Display all records from the Employee table for employees working in the “Marketing” department OR “Finance” Department. Display the Last Names of all employees such that each last name appears only once. Display all the attributes for employees whose employee number is less than 10....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT