Creating a sql file, PL-SQL Programming

Assignment Help:

Creating a SQL file

1. Open a new file in Notepad++ and save it to the location c:\mysql\bin, with the name lab8script.sql (the file extension should be .sql ). Add a MySQL comment to the top of the script file with your name. You will be adding SQL commands to this script file for the remainder of this lab.

2. Next, add to the script file, the command (use statement) to select the classicmodels database. Save the file (but leave it open). Your script now has one comment and one SQL command in it. We will continue to add SQL commands to this file in the next part of the lab.

3. Next, add to the script file, the SQL query that will return the order number, quantity ordered, price each and total cost of an order (quantity * price each) from the order details table. Label the calculated column as "Total Cost" and sort by the total cost.

If you do NOT see any data in your order details table, it means that you did not successfully complete the insert of data into that table as part of lab 4.  Please go back to the course content area in D2L and re-download the file MyLastName_Lab_Module4.txt.  When you open this file, you will see the insert command and all the data for the order details table.  Please review the instructions from lab 4 on how to run this insert statement and populate the order details table before you proceed with this lab. 

1. Now, we want to run the script and test it to see if our select statement is working. Save the lab8script.sql file (but you can leave it open in NotePad++).

2. Open a command prompt on your computer and get into the MySQL monitor. Execute the script file and check your output. If the output is correct, move on to the next step. If the output is wrong: edit the SQL statement in the script file, save the script file, re-run the script from the mysql prompt and check the output.

3. Due to an increase in overhead costs, the buying price of all items needs to be increased. Management wants to see a report before deciding how much each product will go up. Add to the script file, the SQL query that will run against the products table and return the product code, quantity in stock, current buying price and columns to show 3%, 5% and 10% over current buying price. Be sure to label the column headings for the calculated buying price as "3 Percent", "5 Percent" and "10 Percent."You will have a total of 6 column headings.

4. Next, add to the script file, the SQL query that will return the employee number and a concatenation of the first and last names of employees from the employee table. The names should be concatenated and display lastname first as "lastname, firstname"

a. Be sure all these queries are in your lab8script.sql file and that they run successfully and produce the correct results.

Then -

  1. Browse to your notepad++ window with Lab8Script.sql open
  2. Add to the script file, the SQL query that will return the number of offices in each country (Using group by and count)
  3. Be sure all these queries are in your lab8script.sql file and that they run successfully and produce the correct results

Go to

1. Browse to your notepad++ window with Lab8Script.sql open

2. Next, add to the script file, the SQL query that will return the average quantity of products ordered from the order details table

3. Next, add to the script file, the SQL query that will return the minimum quantity of products ordered from the order details table

4. Next, add to the script file, the SQL query that will return the maximum quantity of products ordered from the order details table

5. Be sure all these queries are in your lab8script.sql file and that they run successfully and produce the correct results.

Finally

1. Browse to your notepad++ window with Lab8Script.sql open

2. Next, add to the script file, the SQL query that will retrieve the number of customers in each city in which there are at least 2 customers. (Hint: use the count() function)


Related Discussions:- Creating a sql file

Use serially reusable packages - performance of application, Use Serially R...

Use Serially Reusable Packages To help you to manage the use of memory, the PL/SQL gives the pragma SERIALLY_ REUSABLE that mark some packages as serially reusable . So mark

Theory of catastrophism or catalysm - origin of life, THEO R Y OF CATASTR...

THEO R Y OF CATASTROPHISM OR CATALYSM (CUVIER 1769-1832) - The world has passed thorugh several stages and at the end of each stage there was a catastrophe killing all the

Components of an object type - attributes in pl/sql, Attributes: Just ...

Attributes: Just similar to variable, an attribute is declared with a name and datatype. The name should be exclusive within the object type. The datatype can be any Oracle ty

Oracle development , Write a stored procedure that accepts the post code in...

Write a stored procedure that accepts the post code in which the customer resides as the input parameter. The procedure should then use an explicit cursor to display comprehensive

Definition of from - sql, Definition of FROM - SQL Recall that the ope...

Definition of FROM - SQL Recall that the operand of FROM is denoted by a commalist, each element of that commalist being a table expression optionally accompanied by a range v

Package utl file in pl/sql, UTL_FILE: The Package UTL_FILE permits you...

UTL_FILE: The Package UTL_FILE permits your PL/SQL programs to read & write operating system (OS) text files. It gives a restricted version of the standard OS stream file I/O,

Iterative control:exit statements, EXIT The EXIT statement forces a loop...

EXIT The EXIT statement forces a loop to done unconditionally. Whenever an EXIT statement is encountered, the loop is done immediately and controls the passes to the next statem

Aggregate operators sql, Aggregate Operators SQL Supports all of the a...

Aggregate Operators SQL Supports all of the aggregate operators mentioned in the theory book and many more besides. The syntax, however, involves an unusual trick that SQL cal

Effects of null for union - sql, Effects of NULL for union - SQL The ...

Effects of NULL for union - SQL The treatment of NULL in invocations of EXCEPT is as for UNION. This is different from its treatment in those of NOT IN and quantified compari

Procedure, 1. Create a procedure called TAX_COST_SP to accomplish the tax c...

1. Create a procedure called TAX_COST_SP to accomplish the tax calculation task. Keep in mind that the state and subtotal values are inputs into the procedure and the procedure is

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd