Question

In: Computer Science

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
    1. Write a query to display the current date. Label the column DATE.
    2. Display the last name of all employees who have an A and an E in their last name.
    3. For each employee, display the employee number, last_name, salary, and salary if it were increased by 18%
      and expressed as a whole number.
    4. Modify the previous query to add a column that will subtract the old salary from the new salary. Label the column INCREASE .
    5. Display the employee's name, hire date, and salary review date, which is the first Monday after six months of service. Label the column REVIEW. Format the dates to appear in the format similar to "Sunday, the Seventh of September, 1981.
    6. For each employee display the employee name and calculate the number of months between today and the date the employee was hired. Label the column MONTHS_WORKED. Order your results by the number of months employed. Round the number of months up to the closest whole number.
    7. For each employee, display an output in this format: Employee earns monthly but wants <3 times salary>. Title the column Dream Salaries.
      Dream Salaries
      KING earns $5,000.00 monthly but wants $15,000.00.
      BLAKE earns $2,850.00 monthly but wants $8,550.00.
      CLARK earns $2,450.00 monthly but wants $7,350.00.

    8. Write a query to display name and salary for all employees. Format the salary to be 15 characters long, left-padded with $s. Label the column SALARY.
    9. Write a query that will display the employee's name with the first letter capitalized and all other letters lowercase along with the length of their name, restrict your results to include only employees whose name starts with J, A, or M. Give each column an appropriate label.
    10. Display the name, hire date, and day of the week on which the employee started. Label the column DAY. Order the results by the day of the week starting with Monday.

Solutions

Expert Solution

1). Write a query to display the current date. Label the column DATE.

Query: SELECT sysdate "DATE" FROM dual;

2). Display the last name of all employees who have an A and an E in their last name.

Query: SELECT last_name FROM employees WHERE last_name like '%A%' AND last_name like '%E%';


3). For each employee, display the employee number, last_name, salary, and salary if it were increased by 18% and expressed as a whole number. Label the column New Salary.  

Query: SELECT employee-id, last_name, salary, ROUND(salary * 0.18) "NEW Salary" FROM employees;


4). Modify the previous query to add a column that will subtract the old salary from the new salary. Label the column INCREASE.

Query: SELECT employee-id, last_name, salary, ROUND(salary * 0.18) "NEW Salary", ROUND(salary * 0.18) - salary "INCREASE" FROM employees;

5). Display the employees last_name, hire date, and salary review date, which is the first Monday after six months of service.
Label the column REVIEW. Format the dates to appear in the format similar to "Sunday, the Seventh of September, 1981".

Query: SELECT last_name, hire_date, TO_CHAR(NEXT_DAY(ADD_MONTHS(hire_date,6),'Monday'),'fmday,"the" Ddspath "of" Month, YYYY') REVIEW FROM employees;


6). For each employee display the employee last name and calculate the number of months between today and the date the employee was hired. Label the column MONTHS_WORKED. Order your results by the number of months employed. Round the number of months up to the closest whole number.

Query: SELECT last_name,ROUND(MONTHS_BETWEEN(SYSDATE, hire_date)) MONTHS_WORKED FROM employees ORDER BY months_worked;

7). For each employee, display an output in this format: Employee earns monthly but wants <3 times salary>. Title the column Dream Salaries.
Dream Salaries
KING earns $5,000.00 monthly but wants $15,000.00.
BLAKE earns $2,850.00 monthly but wants $8,550.00.
CLARK earns $2,450.00 monthly but wants $7,350.00.

Query: SELECT lat_name || 'earns' || TO_CHAR(salary, 'fm$99,999.00') || 'monthly_nut_wants' || TO_CHAR(salary*3, 'fm$99,999.00') || '.' "Dream Salaries" FROM employees;

8).Write a query to display name and salary for all employees. Format the salary to be 15 characters long, left-padded with $s. Label the column SALARY.

Query: SELECT last_name,LPAD(salary, 15, $) SALARY FROM employees;


9). Write a query that will display the employee's name with the first letter capitalized and all other letters lowercase along with the length of their name, restrict your results to include only employees whose name starts with J, A, or M. Give each column an appropriate label.


Query: SELECT INITCAP(last_name) "NAME", LENGTH(last_name) "Length" FROM employees WHERE    last_name like 'J%' OR last_name like 'A%' OR lat_name like 'M%' ORDER BY last_name;


10). Display the name, hire date, and day of the week on which the employee started. Label the column DAY. Order the results by the day of the week starting with Monday.


Query: SELECT last_name, hire_date, TO_CHAR(hire_date, 'DAY') DAY FROM employees ORDER BY TO_CHAR(hire_date - 1,'d');


Related Solutions

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 Show the details of the employees who are located in area code 901 and their manager employee number is 108. Show the details of the employees who are also mangers. Show the details of the customers whose balance is greater than 220 but less than 500. Show the details of the customers whose balance is highest. Show customer 10014’s name and the product’s descriptions which he/she purchased and the number...
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 a new SQL Developer SQL worksheet and create/run the following TWO (2) queries and save...
Create a new SQL Developer SQL worksheet and create/run the following TWO (2) queries and save your file as Comp2138LabTest1_JohnSmith100123456.sql (replace JohnSmith 100123456 with your name and student ID). Please place comment that includes your name and your student ID at the top of your script and number your queries using comments sections. Each query carries equal weight. A selection of the expected result set has been shown below for your convenience. Your output should match with this sample output....
how to create a script file on puTTy script pp1.txt
how to create a script file on puTTy script pp1.txt
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you...
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you can submit a zipped file containing the text file. Word, PDF, or Image format are not accepted. You do not need to show screen shot. Make sure you have tested your SQL statements in Oracle 11g. Problem 1. Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. [30 points] Assumptions: Each tool belongs to a category....
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you...
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you can submit a zipped file containing the text file. Word, PDF, or Image format are not accepted. You do not need to show screen shot. Make sure you have tested your SQL statements in Oracle 11g. The list of tables is: Tables: Cust Table: cid, -- customer id cname, --- customer name cphone, --- customer phone cemail, --- customer email Category table: ctid, ---...
Create a separate file to answer the following questions and then submit it below. Draw the...
Create a separate file to answer the following questions and then submit it below. Draw the complete graph for each question. a. Draw a graph of the market for jalapeno peppers. Be sure to label everything. b. Draw a new graph that shows what changes would occur to your graph in part ‘a’ if there was bad weather and the jalapeno pepper crop was severely damaged. Explain why you made these changes to the graph. c. Redraw the graph you...
Complete each problem on a separate worksheet in a single Excel file. Rename the separate worksheets...
Complete each problem on a separate worksheet in a single Excel file. Rename the separate worksheets with the respective problem number. You may have to copy and paste the datasets into your homework file first. Name the file with your last name, first initial, and HW #2. Label each part of the question. When calculating statistics, label your outputs. Use the Solver add-in for these problems. For a telephone survey, a marketing research group needs to contact at least 600...
Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT