Question
You will be using data in your own database. If you already have a vwPlayersBatting view, you don't need to recreate it. Make sure you
You will be using data in your own database. If you already have a vwPlayersBatting view, you don't need to recreate it.
Make sure you have not altered any data in the tables. You will need to use your Player to Batting view for several problems. Watch carefully. In many problems, I ask for names not to repeat. This is because a player's name will repeat in vwPlayerBatting once for each year they played. Adding the player's ID and distinct will work in vwPlayerBatting. But you only need the view when there is related data such as playerName (players) and teamID (batting), or maybe playerName and yearID. Look at the question. If you can pull all data from players (name & birthdate), or all data from players (playerID and team), don't use the view - use the table.
1. Generate a spin-off table from Batting (not a join - using Players) of all Seattle Mariner players. Unlike a view, which provides real-time access to data, a spin-off table is a snapshot of the data as it appears at that moment. Add an INTO clause right before the FROM clause in a SELECT. Follow the INTO with the new table name MarinerMast. A new table will be generated. You can identify Mariner records where the team ID is SEA
2. Create a View, by hand, of the previous SELECT of Seattle players (less the INTO). Name the view VWSeattlePlayers and provide the script.
Note: If I were now to change data in the Players table, the view would reflect those changes whereas the spin-off table would not.
For the remainder of these problems use either the playersBatting view, the players' table or the batting table.
3. Using the Players table, a WHERE, and AND statements, develop a SELECT to pull all players with weights between 200 and 250 pounds inclusive. Include the player's name and date of birth.
4. Solve the previous problem using a BETWEEN statement.
5. Modify the previous problem to give me everyone that does not weigh between 200 and 250 pounds.
6. Using a CASE statement, provide a list of player names (first and last concatenated like Flintstone, Fred) with the header Name, and Left if they bat Left (L), Right if they bat Right (R), Both if they bat Both, or Unknown if the field is empty or null.
7. Provide a list of players (using Between), that played their debut game sometime during the 1950s. Dates must be in apostrophes. No repeated players.
8. Use an IN statement and your view, to return all player names born in one of these States WA, OR, ID, or CA.
9. Provide a list of all foreign countries (non-USA) in which players were born. Do not allow countries to repeat on the list. Order the list alphabetically.
10. Which left-handed batters were born in either Texas, New York, or California, played for the New York Yankees (teamID: NYA), and weighed less than 200. No repeated players.
11. Write a SELECT to return the players names, team, year, weight, and either SMALL, MEDIUM, LIGHT, HEAVY, or HUGE based on their weight. Small is <150. Light is 150-175, Medium is 176-220, Heavy is 221-250 and Huge is larger than 250 pounds. If weight is null, display UNKNOWN.
12. Create a view by hand from the last problem named vwWeightDistribution (provide the entire command). Demonstrate the command using your view that would produce weight distribution for the players that played for the Los Angeles Dodgers (LAN).
13. Write a SELECT listing the first and last names of all players with ROB at the start of their last name. Do not repeat a name.
14. Write a SELECT that will return to me all players born in a country with US anywhere in its column that hit 20+ home runs (hr) in a season. No repeated players.
15. Generate a single SELECT that returns the roster for the 1987 Seattle Mariners (SEA) and 1987 New York Yankees combined. Sort by the team, last name, then first. Include full name and a calculated column, "Team" listing the team's name spelled out: Mariners, Yankees.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started