P.S: If your answer sheet is different, lets us know and we would surely like to look into it. Pls feel free to drop us a message at [email protected]. We would surely help you with it
BIS345: Data Analysis for Business
Lab 1 Questions:
Lab 1 Student Answer Sheet
Student Name:
Using Lab 1, answer the questions and provide copies of your SQL Statements and/or results for each Section listed below
Part A: Customer List (4 points)
a. What does the ORDER BY clause do?
b. Screen print your results and paste here:
Part B: Customer List with only customers In France or Germany (4 points)
a. What do you need to fill in the WHERE clause?
b. Paste your SQL Statement here:
c. Screen print your results and paste here:
Part C: Using a Calculation in a Query (5 points)
a. Screen print your results and paste here:
Part D: Products that are discontinued (5 points)
a. What condition should you put on WHERE clause?
b. Paste your SQL Statement here:
c. Screen print your results and paste here:
Part E: Practice using the BETWEEN operator (5 points)
a. What condition should you put after the WHERE clause when using the BETWEEN operator?
b. Paste your SQL Statement here:
c. Screen print your results and paste here:
Part F: Practice using the “IN” operator (5 points)
a. What does the “IN” operator do?
b. Screen print your results and paste here:
Part G: Understanding “NULL” (5 points)
a. What is NULL?
b. How is NULL different from blank spaces?
c. Can NULL only be used with IS operator?
d. What if you change the “IS” operator to “=”?
e. Screen print your results and paste here:
Part H: Using a composite condition (5 points)
a. What did you put in the where clause?
b. Is ShipCountry= ‘France’ the same as ShipCountry= ‘FRANCE’?
c. Are the column, table and value parts of the SQL script case sensitive?
d. Paste your SQL Statement here:
e. Screen print your results and paste here:
Part I: Using a “DATE” type variable and Concatenating Column Output (5 points)
a. In the Select Statement, how does SELECT FirstName + ‘ ‘ + LastName as “Name” affect the output results?
b. Screen print your results and paste here:
Part J: Using the “LIKE” operator and the “%” wildcard (6 points)
a. What did you put in the WHERE clause’s LIKE operator?
b. What would happen if you did not use the “%” wildcard with the LIKE operator?
c. Paste your SQL Statement here:
d. Screen print your results and paste here:
Lab 1: Single Table SQL Queries
Overview
Using the Northwind database, you must select data for specific needs, as requested of you. Once selected, your data will be presented to management. You will have to determine which fields are the most appropriate to be selected. Do not include any fields that management does not need to see.
Below is a screen shot of the Northwind Database schema:
You will log into our Citrix Server, access SQL Server and the Northwind database, and then write some queries using SQL. These queries extract information from a single table.
Part A
You have been requested to provide a customer list. The list must show customer name, contact person, and how to contact the company via mail and phone. Northwind Traders has many overseas customers, so the list must be sorted in country order and the customers in each country must also be sorted in alphabetical order.
As you prepare to create this query, decide what information needs to be displayed – this will be listed in the SELECT clause. Review the tables to determine what table to use – this will be listed in the FROM clause. Determine the field(s) needed to order the output – this will be listed in the ORDER BY clause.
1. Using the query window, type the SELECT statement needed to produce the desired results. The SQL is given below:
2. After you’ve typed your query, click on the Execute button to run the query and see the results.
Not all rows are visible in the image, but your result set should look like this:
3. Open up the Lab 1 Student Answer Sheet located in Doc Sharing, and answer the questions related to this part of the lab.
4. You must provide copies of your SQL statement and/or results. You may be asked to take a screenshot or cut and paste the SQL into the Word document. Follow the instructions on your lab answer sheet.
(To take a screenshot, press CTRL-ALT-PRINTSCREEN. Nothing appears to happen on your screen, but this set of keystrokes places a picture of your screen on the clipboard. In Word, just use your mouse to put the cursor where you want the screenshot to go, and then right click and press Paste. The screenshot will appear in your Word document after a few seconds.)
Part B
Change the SQL from No. 1 so that only the customers in France and Germany are displayed.
This problem continues from the first question. It produces the same list, but only certain customers are to be displayed. This requires you to restrict the rows being returned to only customers in certain countries. How do you restrict rows? You will need to add a WHERE clause. What will the condition be? The Country field contains the names of the country; you want to see the customers living in either France OR Germany. Where do you place the WHERE clause? The WHERE clause goes immediately after the FROM clause. When you have typed your query, click on the Execute button to run the query and see the results.
1. The SQL that accomplishes this task is listed below. Type it into your SQL Window:
2. Press the Execute Button to get this result (not all rows are visible in the image):
3. Answer the questions under Part B of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Supplementary Note: Instead of using the logical operator OR, you could also use the special operator IN to get the same result set. Here is an alternate solution:
Part C
You have been requested to provide a list of products sold by the company. Along with the product name, show the unit price, the number of items in stock for each product, and the total value (dollar amount) of the items in stock. The products must be listed in descending order of value.
1. This problem requires a new SQL statement. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. What table will this information come from? Products. (FROM clause)
b. What fields have been requested? Product name, unit price, units in stock, and the total value of the items in stock. Check the table for the exact field names. (SELECT clause)
c. Where will total value come from? It is not in the table. This will be a calculated field. The total dollar value will be the result of multiplying unit price by units in stock.
d. Give the calculated field column a name (known as an alias).
e. In what order will the results be listed? Remember, the ORDER BY clause can use a field name or the field’s position in the SELECT clause.
The first rows in the result set will be:
2. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database. Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part C of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part D
Management wants to see the same details as in the previous list, but only for the products that have been discontinued.
This problem will use a similar SELECT statement as in the previous question. The same fields are required, but there is a restriction on the rows.
1. Use the same query that is currently in the query window.
2. How will you change it to return only the products that are discontinued?
What field will be included in the WHERE clause?
What does this field contain – the words Yes or No? This is important to know because it will affect how you test it. The Discontinued field is a bit datatype; a bit can hold 1, 0, or NULL. The string values ‘True’ and ‘False’ can be converted to bit. ‘True’ is 1 and ‘False’ is 0. That means you can test Discontinued being either 1 or ‘True’ in your WHERE clause.
The results returned will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part D of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part E
Management wants to see the same details as in the previous problem, but only list the products for which the in-stock quantity is between 100 and 200 items.
This problem will use the same SELECT statement as in question 4. The same fields are required, but there will be a different restriction on the rows.
1. Use the same query that is currently in the query window.
2. Delete the existing WHERE clause.
3. How will you change it to return just the products that have an in-stock quantity between 100 and 200 items?
What field will be in the WHERE clause? Between 100 and 200 items is testing for a range of values.
What comparison operator will you use to test this field? There is more than one way to write the WHERE clause.
The results returned will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
4. Answer the questions under Part E of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part F
This question will require a new query.
You have been requested to provide a list of our suppliers in Canada, Brazil, and the U.S.A. For each supplier provide the company name and contact information of the supplier. Sort the list into an appropriate order.
1. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database.
2. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. From what table will this information come? Suppliers. (FROM clause)
b. What fields have been requested? Look at the table and decide exactly what fields will be required for the purposes of contacting this company. (SELECT clause)
c. The list will be limited to certain countries. What field will you be testing in the WHERE clause?
d. There is more than one country; will you need a logical operator? Or is there a special operator you can use? Again, there is more than one way of writing the WHERE clause.
e. What order makes the most sense for the results to be listed in? Remember, the ORDER BY clause can use a field name or the field’s position in the SELECT clause.
The results returned will be as follows (not all the fields are showing in the screenshot):
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part F of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part G
The Marketing Department wants to send details of upcoming sales events to customers via fax. If a customer has not provided a fax number, then some other form of communication must be used to notify them of the sales events. Provide a list of customers who do not have a fax number; include a contact person name and phone number. Sort the list in an appropriate order.
1. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database.
2. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. From what table will this information come? Customers. (FROM clause)
b. What fields have been requested? Look at the table and decide exactly what fields will be required for the purposes of contacting these customers. (SELECT clause)
c. The list will be limited to customers who do not have a fax number. What field will you be testing in the WHERE clause?
d. How will you know if there is no fax number? The field will contain a NULL. How do you test a field for NULL?
e. What order makes the most sense for the results to be listed in? Remember, the ORDER BY clause can use a field name or the field’s position in the SELECT clause.
The first rows in the result set will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part G of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part H
The Marketing Department wants to examine freight charges for orders shipped within the U.S.A. Produce a list showing the order ID, the date of the order, the shipping company used (ShipVia field), the freight, and the country specified in the shipping address. Limit the list to orders with a freight charge of more than $50.
1. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database.
2. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. From what table will this information come? Orders. (FROM clause)
b. What fields have been requested? Look at the table and decide exactly what fields will be required. (SELECT clause)
c. The list will be limited by two separate criteria. What are they? What fields will you be testing in the WHERE clause?
The first rows in the result set will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part H of your Lab Answer Sheet and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part I
Produce a list of Employees hired after 1/1/1994. Include the employee first and last names concatenated into one field, their position (title), and hire date. Sort the list in last-name order.
1. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database.
2. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. From what table will this information come? Employees. (FROM clause)
b. What fields have been requested? Look at the table and decide exactly what fields will be required. (SELECT clause)
c. The employee name will be a calculated field combining first name and then last name – you will be transforming strings for this calculated field. Don’t forget to use a column alias.
d. Only list the employees hired after 1/1/94. What field will you be testing in the WHERE clause? Date fields are enclosed in single quotes, just like string fields.
The result set will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part I of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
Part J
Management would like to see a list of the tofu products we currently stock. List all products that have tofu in the name of the product.
1. You can either work in the current query window by deleting the existing statement that has already been pasted into your Word document, or open a new query window by clicking on the New Query tool on the toolbar. You should still be accessing the Northwind database.
2. Read the problem statement carefully and then review the tables. Build the statement step by step:
a. From what table will this information come? Products. (FROM clause)
b. What fields have been requested? The fields have not been specified, so use your judgment. Look at the table and decide exactly what fields to include. (SELECT clause)
c. We don’t know where in the product name field the word ‘tofu’ appears. That means we can’t test for a field to be exactly equal to tofu. We will have to use the wildcard operator and the keyword LIKE.
The result set will be:
Try the statement on your own; if you have problems, check the solution at the end of this document.
3. Answer the questions under Part I of your Lab Answer Sheet, and paste the first SELECT statement and a screenshot of the result set into a Microsoft Word document. Your SQL must be cut and pasted from your SQL window, and should NOT be a screenshot. However, you should use a screenshot of the result set as you did in the previous question. The screenshot should show at least the first ten rows of the results.
You have now completed Lab 1. Well done! Submit your Word document to the Week 1 iLab Dropbox.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.