Question

In: Computer Science

Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios. Use MySQL...

Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios.

Use MySQL and the Colonial Adventure Tours database to complete the following exercises.

1. List the last name of each guide that does not live in Massachusetts (MA).

2. List the trip name of each trip that has the type Biking.

3. List the trip name of each trip that has the season Summer.

4. List the trip name of each trip that has the type Hiking and that has a distance longer than 10 miles.

5. List the customer number, customer last name, and customer first name of each customer that lives in New Jersey (NJ), New York (NY) or Pennsylvania (PA). Use the IN operator in your command.

6. Repeat Exercise 5 and sort the records by state in descending order and then by customer last name in ascending order.

7. How many trips are in the states of Maine (ME) or Massachusetts (MA)?

8. How many trips originate in each state?

9. How many reservations include a trip price that is greater than $20 but less than $75?

10. How many trips of each type are there?

11. Colonial Adventure Tours calculates the total price of a trip by adding the trip price plus other fees and multiplying the result by the number of persons included in the reservation. List the reservation ID, trip ID, customer number, and total price for all reservations where the number of persons is greater than four. Use the column name TOTAL_PRICE for the calculated field.

12. Find the name of each trip containing the word “Pond.”

13. List the guide’s last name and guide’s first name for all guides that were hired before June 10, 2013.

14. What is the average distance and the average maximum group size for each type of trip?

15. Display the different seasons in which trips are offered. List each season only once.

16. List the reservation IDs for reservations that are for a paddling trip. (Hint: Use a subquery.)

17. What is the longest distance for a biking trip?

18. For each trip in the RESERVATION table that has more than one reservation, group by trip ID and sum the trip price. (Hint: Use the COUNT function and a HAVING clause.)

19. How many current reservations does Colonial Adventure Tours have and what is the total number of persons for all reservations?

Solutions

Expert Solution

Solution

1)
SELECT LAST_NAME FROM GUIDE
WHERE STATE <> 'MA';

2)
SELECT TRIP_NAME FROM TRIP
WHERE TYPE='Biking';

3)
SELECT TRIP_NAME FROM TRIP
WHERE SEASON='Summer';

4)
SELECT TRIP_NAME FROM TRIP
WHERE TYPE='Hiking' AND DISTANCE > 10;

5)
SELECT CUSTOMER_NUM, LAST_NAME, FIRST_NAME FROM CUSTOMER
WHERE STATE IN('NJ','NY','PA');

6)
SELECT CUSTOMER_NUM, LAST_NAME, FIRST_NAME FROM CUSTOMER
WHERE STATE IN('NJ','NY','PA')
ORDER BY STATE DESC,LAST_NAME ASC;

7)
SELECT COUNT(*) FROM TRIP
WHERE STATE IN('ME','MA');

8)
SELECT STATE, COUNT(TRIP_ID) FROM TRIP
GROUP BY STATE
ORDER BY STATE;

9)
SELECT COUNT(*) FROM RESERVATION
WHERE TRIP_PRICE>20 AND TRIP_PRICE<75;

10)
SELECT TYPE, COUNT(TRIP_ID) FROM TRIP
GROUP BY TYPE
ORDER BY TYPE;

11)
SELECT RESERVATION_ID, TRIP_ID, CUSTOMER_NUM,
(TRIP_PRICE+OTHER_FEES)*NUM_PERSONS AS TOTAL_PRICE
FROM RESERVATION
WHERE NUM_PERSONS>4;

12)
SELECT TRIP_NAME FROM TRIP
WHERE TRIP_NAME LIKE '%Pond%';

13)
SELECT LAST_NAME, FIRST_NAME FROM GUIDE
WHERE HIRE_DATE<20130610;

14)
SELECT TYPE, AVG(DISTANCE), AVG(MAX_GRP_SIZE) FROM TRIP
GROUP BY TYPE;

15)
SELECT DISTINCT SEASON FROM TRIP;

16)
SELECT RESERVATION_ID FROM RESERVATION
WHERE TRIP_ID IN
(SELECT TRIP_ID FROM TRIP WHERE TYPE='Paddling');

17)
SELECT MAX(DISTANCE) FROM TRIP
WHERE TYPE='Biking';

18)
SELECT TRIP_ID,SUM(TRIP_PRICE) FROM RESERVATION
GROUP BY TRIP_ID
HAVING COUNT(*)>1;

19)
SELECT COUNT(*), SUM(NUM_PERSONS) FROM RESERVATION;

--

Answered all the questions

if you have any doubt, please mention it, love to help

all the best

please upvote


Related Solutions

Using MySQL Workbench to write and run the following steps, and take a screenshot for me!...
Using MySQL Workbench to write and run the following steps, and take a screenshot for me! Create a species table and a specimen table. In the species table, include attributes that reflect the name of the species, a general description of the species, and any other attributes you feel relevant. In the specimens table, include an ID for the specimen, a reference to the species which it is, the date which it was observed, and any relevant details like height,...
In MySql, using Application MYSQL Workbench and the Chinook database, please answer the following: -- 12....
In MySql, using Application MYSQL Workbench and the Chinook database, please answer the following: -- 12. SELECT the trackid, name and filesize (as shown in the bytes column) for all tracks that have a file size less than 2000000 and a GenreId of 1 or a file size less than 2000000 and a Genreid of 2 -- 13. Add a sort to the query from number 12 to sort by GenreID; -- 14. List all columns from the customer table...
Part 2: Use MySQL Workbench to add a table to your database on the class server...
Part 2: Use MySQL Workbench to add a table to your database on the class server and name the table “Person”. Include these fields in the Person table: Field Name Description Data Type Sample Value LoginID User’s login name varchar(10) Bob FirstName User’s first name varchar(50) Bob LastName User’s last name varchar(50) Barker picUrl Filename of the user’s picture varchar(50) bob.gif Bio User’s biography varchar(255) Bob is the best! LoginID should be the Primary Key of the table. Add at...
Using the world_x database you installed on your MySQL Workbench, create a new table named “independence”...
Using the world_x database you installed on your MySQL Workbench, create a new table named “independence” with the following attributes (columns): A field named “id” which has data type auto_increment, A field named “country_name” which has data type varchar(50), and A field named “independence_date” which has type “date.” After you create the table, run the following SQL command: INSERT INTO independence(country_name, independence_date) VALUE (‘United States’,’1776-07-04’) Submit a 1-page Microsoft Word document that shows the following: The SQL command you used...
) Write queries for the following. Include screenshots of the queries and the outputs. Create a...
) Write queries for the following. Include screenshots of the queries and the outputs. Create a procedure named DisplayInfo which takes customer name as a parameter and displays information of that customer. (database – sql_store)
Screenshots from MySQL (or any other software you use) of all the tables after queries result...
Screenshots from MySQL (or any other software you use) of all the tables after queries result sorry no spam i will be reported no copy and paste i want complete answer with Screenshots no handwriting thanks for your efforts and time Using the info below, write a query SQL Using the info below to Normalize the Tables (in 3NF at least) . Using the info below toCreate the Normalized Tables and Populate them with at least 5 Rows . Using...
**Need to use awk command in putty (should be a ONE LINE COMMAND) Write the command...
**Need to use awk command in putty (should be a ONE LINE COMMAND) Write the command that would find all lines that have an email address and place a label email = before the line in the file longfile output will multiple lines similar to this one : using a good awk command the output would be something like this email = From: "Linder, Jann/WDC" <[email protected]> email = To: Mr Arlington Hewes <[email protected]> email = > From: Mr Arlington Hewes...
Research Managing Files via the Command Line Interface (CLI) commands, flags, and options that allow you...
Research Managing Files via the Command Line Interface (CLI) commands, flags, and options that allow you to: copy, delete, rename, and move files on Windows and Linux.
Please look at the following code. When I run it from the command line, I am...
Please look at the following code. When I run it from the command line, I am supposed to get the following results: 1: I am 1: I am I need to fix it so that the functions 'print_i' and 'print_j' print all of their lines. What do I need to add? Thank you. C source code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <unistd.h> // These two functions will run concurrently void* print_i(void *ptr) { printf("1: I am...
Use MySQL server. First step: create and use database called EDU. Syntax: CREATE SCHEMA edu; USE...
Use MySQL server. First step: create and use database called EDU. Syntax: CREATE SCHEMA edu; USE edu; Create a script which will create the tables listed below: STUDENT(STUDENT_ID, STUDENT_NAME, MAJOR_ID, DOB, PHONE_NUMBER) MAJOR(MAJOR_ID, MAJOR_NAME) ENROLLMENT(STUDENT_ID, COURSE_ID, GRADE) COURSE(COURSE_ID, COURSE_NAME) RESPONSIBILITY(FACULTY_ID, COURSE_ID) TEACHER(FACULTY_ID, DEPT_ID, TEACHER_NAME) DEPARTMENT(DEPT_ID, DEPARTMENT_NAME) Start the script with a series of DROP statements so that as you correct mistakes you will start fresh each time. To avoid referential integrity errors, the table drops should be in the opposite...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT