Starting from:

$29.99

DBS3110 Lab 01 – Single-row Functions Solution


This week’s lab continues using the SELECT command and learning the interfaces for both SQL Developer and introduces the use of single-line functions.
Submission
Your submission will consist of two files:
(a) A single text-based SQL file with appropriate header and commenting – and
(b) An output file demonstrating that your queries work
Please ensure your SQL file runs when the entire file is executed.
Your file names should be L01-lastname-firstname
For example: L01-King-Les.sql and L01-King-Les.output or L01-King-Les.pdf, etc.
Your submission needs to be commented. At a minimum, your comments before each SQL statement should include the complete question below you are answering. Tasks
the result will depend on the day when you RUN/EXECUTE this query. Label the column “Tomorrow”.

See the following example:
select * from employees where employee_id = 107;
You can also have the following code:
define emp_id number = 107; select * from employees where employee_id = &emp_id;
After you use the variable, you can undefined the variable:
undefine emp_id;
Define a variable of type datetime:
define tomorrow = sysdate + 1;

-- Q3: For each product in category 2, 3, and 5, show product ID, product name, list price, and the new list price increased by 2%. Display a new list price as a whole number.
In your result, add a calculated column to show the difference of old and new list prices.
Sort the result according to category ID first and then based on product ID.
You output has to match the following result. This result is partially displayed as it has 158 rows.
See the result for the first 10 rows.

-- Q4: For employees whose manager ID is 2, write a query that displays the employee’s Full Name and Job Title in the following format:
Summer, Payne is Public Accountant.
Sort the result based on employee ID.

• Label the column Years worked.
• Order your results by the number of years employed. Round the number of years employed up to the closest whole number.
The output result includes 89 rows. See the partial result (The first 10 rows).

• Label the column REVIEW DAY.
• Format the dates to appear in the format like:
You can use ddspth to have the above format for the day.
The Query returns 107 rows. See the first 10 rows of the output result.

-- Q7: For all warehouses, display warehouse id, warehouse name, city, and state. For warehouses with the null value for the state column, display “unknown”. Sort the result based on the warehouse ID.

Example Submission
-- ***********************
-- Name: Your Name
-- ID: #########
-- Purpose: Lab 1 DBS311
-- ***********************

-- Question 1 – Copy the question from above here
-- Q1 SOLUTION --

SELECT * FROM TABLE;

-- Question 2 – Copy the question from above here
-- Q2 Solution –
SELECT * FROM TABLE;



More products