Write a query that displays the order id and order date

Assignment Help Database Management System
Reference no: EM131072701

Lab: Introduction to Select, Insert, Update, and Delete Statements

LAB OVERVIEW

Lab will introduce the various aspects of the SQL select statement and the methods of retrieving data from the database tables. This lab will also introduce the fundamentals of updating and deleting records. This lab may be completed using either DeVry's Omnymbus EDUPE-APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the instructions in the file CreateOMTables.docx to create your database, tables, and data.

A few IMPORTANT things to note if using EDUPE MySQL:

**There can be NO SPACES in alias names given to a column. For example:

Select unit_price as "Retail Price " from items; --this does NOT work in EDUPE MySQL.

Any of the following WILL WORK:

Select unit_price as "RetailPrice" from items;
Select unit_price as "Retail_Price" from items;
Select unit_price as Retail_Price from items;
Select unit_price as RetailPrice from items;

**Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example:
selectunit_price * 2 from items; --this does NOT work in EDUPE MySQL

This will work:

selectunit_price * 2 as NewPricefrom items;

Deliverables

• Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file.

LAB STEPS: Complete each of the exercises below.

1. Write a query that displays a list of all customers showing the customer first name, last name, and phone number. Sort the results by customer last name, then first name.

2. Write a query that displays each customer name as a single field in the format "firstnamelastname" with a heading of Customer, along with their phone number with a heading of Phone. Use the IN operator to only display customers in New York, New Jersey, or Washington D.C. Sort the results by phone number.

3. Write a query that will list all the cities that have customers with a heading of Cities. Only list each city once (no duplicates) and sort in descending alphabetical order.

4. Write a query that displays the title of each item along with the price (with a heading of Original) and a calculated field reflecting the price with a 25% discount (with a heading of Sale).Display the sale pricewithtwo decimal places using the ROUNDfunction. Sort by price from lowest to highest.

5. Write a query that displays the customer_first_name, customer_last_name, and customer_city from the customers table. Use the LIKE operator to only display customers that reside in any zipcode beginning with 4.

6. Write a query that displays the order id and order date for any orders placed from March 1, 2014 through April 30, 2014. Do this WITHOUT using the BETWEEN clause. Format the date field as Month dd, yyyy and use a heading of "Ordered".

7. Write a query that displays the order id and order date for any orders placed during the month of May, 2014. Do this using the BETWEEN clause. Format the date field as mm/dd/yy and use a heading of "Ordered".

8. Write a query which displays the order id, customer id, and the number of days between the order date and the ship date (use the DATEDIFF function). Name this column "Days" and sort by highest to lowest number of days. Only display orders where this result is 15 days or more.

9. Write a query which displaysthe order id, customer id and order date for all orders that have NOT been shipped, sorted by order date with the most recent order at the top.

10. The Marketing Department has requested a new report of shipped orders for which the order was placed on either a Saturday or a Sunday.Write a query which displays the order id, order date, shipped date, along with a calculated column labeled "Order_Day" showing the day of the week the order was placed (use the DAYNAME function). Only display orders that have shipped and were placed on a Saturday or Sunday. Sort by order date with most recent orders at the top.

11. Write a query to display the customer last name, phone number, and fax number but only display those customers that have a fax number.

12. Create astatement to insert a new record into the items table with the following values:

item_id:

11

title:

Ode To My ERD

Artist_id:

15

unit_price:

12.95

ShowyourINSERT statement along with the results of the followingSELECT query to verify that the insert worked correctly.
select * from items where item_id> 10;

13. Create astatement to update the record inserted in the previous step to change the unit price of this itemto 7.95.

item_id:

11

title:

Ode To My ERD

artist:

15

unit_price:

7.95

Show yourUPDATE statement along with the results of the followingSELECT query to verify that the insert worked correctly.

select * from items where item_id> 10;

14. Create a statement to delete the entire record that was inserted and then updated in the previous steps.

Show your DELETE statement along with the results of the following SELECT query to verify that the insert worked correctly.

select * from items where item_id> 10;

15. Using the SUBSTRING and CONCAT functions, write a query to display each customer name as a single field in the format "Jones, Tom" with a heading of Customer along with the customer_phone field in a nicely formatted calculated column named Phone. For example, a record containing the customer_phone value 6145535443 would be output with parentheses, spaces, and hyphens, like this: (614) 555-5443. Sort by last name.

Attachment:- Create_Order_Management_Tables.rar

Reference no: EM131072701

Questions Cloud

Find particular solution using undetermined coefficient : Use the method of undetermined coefficients to find the particular solution. Write your answer in the form yp(t) = Rcos(t-δ). Show the solution steps
Extension with growth and cost of equity : The market value of Firm L's debt is $200,000 and its yield is 9%. The firm's equity has a market value of $300,000, its earnings are growing at a rate of 5%, and its tax rate is 40%. A similar firm with no debt has a cost of equity of 12%. Under the..
What business noticed online for dentures and funeral homes : Depending on the business if the Social Media is too flashy I may be put off. If the Social Media is not flashy enough I may think they are amateurs. What business have you noticed online for dentures, funeral homes, and reverse mortgages?
Why is the latter type of locks preferable : Why is the latter type of locks preferable?
Write a query that displays the order id and order date : Write a query that displays the order id and order date for any orders placed during the month of May, 2014. Do this using the BETWEEN clause. Format the date field as mm/dd/yy and use a heading of "Ordered".
Does it occur only under specific circumstances : Where does this issue occur? In other words, is it more common in urban areas, in some parts of the country, in some countries, etc.? When does this issue occur? Does it occur only under specific circumstances? If so, what are these?
The communication competency about united technologies : After reading the Communication Competency about United Technologies, identify the key behaviors demonstrated by senior leaders to reinforce the company's diversity programs.
Calculate the correlation coefficient between two securities : The Covariance between Stock A and Stock B is 0.02. The Standard deviation of Stock A is 12 % and that of Stock B is 25 %. Calculate the correlation coefficient between the two securities.
Identify and describe an ethical dilemma or issue : Identify and describe an ethical dilemma or issue created by some organizational change effort with which you are familiar. How was the ethical problem handled? What, if anything, would you do differently?

Reviews

Write a Review

Database Management System Questions & Answers

  Create the relational model

Create the relational model corresponding to the described application. Basically, list the CREATE TABLE statements with the attribute names, and appropriate data types.

  Identify any referential integrity violations, if any

Given the following data types of some table fields and the simple schema of the relational database they are a part of, inspect its relationships for any referential integrity violations

  Referential integrity constraint prevent from data inserting

What actions does a referential integrity constraint prevent from occurring when data is inserted in a table that contains this constraint?

  Why is a documentation plan important

What are the key components of change theory and how can they be put into practice?

  Assume that a student table in a university database has an

assume that a student table in a university database has an index on studentid the primary key. and additional indexes

  Find pairs of sids such that the supplier with the ?rst sid

Find pairs of sids such that the supplier with the ?rst sid charges more for some part than the supplier with the second sid.

  Build entity relationship model military information system

Build an entity relationship model for the above scenario. Show all attributes and indicate all of your key attributes in red.

  Online transactions versus a data warehouse optimized

Outline the main differences between the structure of a relational database optimized for online transactions versus a data warehouse optimized for processing and summarizing large amounts of data

  Determine the commissions paid to specific employees

Design a query that will allow the finance department to determine the commissions paid to specific employees of the sales department for the month of December.

  Write a join query that for every order placed on september

Write a join query that for every order placed on September 5, 1998, (use '05-SEP-1998') will list the order number and order date along with the customer number, last name, and first name of the customer who placed the order

  Imagine that you work for a finance industry-based

imagine that you work for a finance industry-based organization. your organization is looking to submit its database

  Triangle classification specification

Consider the triangle classification specification. The system reads in three positive values from the standard input. The three values A,B, and C are interpreted as representing the lengths of the sides of a triangle.

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