SlideShare a Scribd company logo
1 of 21
USE IMDB -- ensures correct database is active
GO
PRINT '|---' + REPLICATE('+----',15) + '|'
PRINT 'Read the questions below and insert your queries where
prompted. When you
are finished,
you should be able to run the file as a script to execute all
answers sequentially
(without errors!)' + CHAR(10)
PRINT 'Queries should be well-formatted. SQL is not case-
sensitive, but it is
good form to
capitalize keywords and table names; you should also put each
projected column on
its own line
and use indentation for neatness. Example:
SELECT Name,
CustomerID
FROM CUSTOMER
WHERE CustomerID < 106;
All SQL statements should end in a semicolon. Whatever
format you choose for your
queries, make
sure that it is readable and consistent.' + CHAR(10)
PRINT 'Be sure to remove the double-dash comment indicator
when you insert your
code!';
PRINT '|---' + REPLICATE('+----',15) + '|' + CHAR(10) +
CHAR(10)
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 1 [3pts possible]:
Write the query to display the name and year of birth for all
people born after
1980, who have
directed at least one show (i.e. those who appear at least once in
the
title_directors table).
Limit results to those who have died (who have a value in the
deathYear column).
---------------------------------------------------------------------------
-------
------------
Columns to display: name_basics.primaryName,
name_basics.birthYear
Sort in descending order by birth year.' + CHAR(10)
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 2 [3pts possible]:
Show every genre of television show which has had at least one
title with 500
episodes.
i.e. limit results to the titleType ''tvEpisode'' in the title_basics
table, and
to titles
containing a row in the title_episode table with episodeNumber
500.
---------------------------------------------------------------------------
-------
------------
Columns to display: title_genre.genre
Display genre name only, and eliminate duplicate values.' +
CHAR(10)
GO
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 3 [3pts possible]:
Write a common table expression to identify the WORST shows:
join title_basics
against title_ratings
and limit your results to those with an averageRating value
equal to 1. Project
the title,
type, and startYear from title_basics; and label your CTE as
BADSHOWS.
In the main query, show a breakdown of BADSHOWS grouped
by type, along with the
total number of
rows for each (i.e. GROUP BY titleType)
---------------------------------------------------------------------------
-------
------------
Columns to display: titleType, COUNT(*)
Sort results in descending order by COUNT(*).' + CHAR(10)
GO
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 4 [3pts possible]:
Identify the least popular professions. Show each profession
value from the
name_profession table,
along with the total number of matching rows (GROUP BY
profession). Use the
HAVING clause to limit
your results to professions with less than 1,000 rows.
---------------------------------------------------------------------------
-------
------------
Columns to display: name_profession.profession, COUNT(*)'
+ CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 5 [3pts possible]:
Use the query from #4 above to display the names of all people
belonging to these
professions.
Use the previous query as a subquery in the FROM clause here
to limit the results.
---------------------------------------------------------------------------
-------
------------
Columns to display: name_basics.primaryName,
name_profession.profession
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 6 [3pts possible]:
Show the name of every writer, along with the total number of
titles they''ve
written (i.e. rows in the
title_writers table). Limit results to those who have written
between 5,000 and
10,000 titles (inclusive).
---------------------------------------------------------------------------
-------
------------
Columns to display: name_basics.primaryName, COUNT(*)
Sort results in descending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 7 [3pts possible]:
Show the actor and character names for everyone who has
performed the same role in
more than one
show with the title ''Battlestar Galactica''. i.e. identify the
combination of
(primaryName, characters)
which occurs in the title_principals table more than once for
matching titles.
---------------------------------------------------------------------------
-------
------------
Columns to display: name_basics.primaryName,
title_principals.characters,
COUNT(*)
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 8 [3pts possible]:
Identify the names of people who have directed more than five
highest-rated shows
(i.e. title_ratings.averageRating = 10).
For each of these people, display their names and the total
number of shows they
have written.
---------------------------------------------------------------------------
-------
------------
Columns to display: name_basics.primaryName, COUNT(*)
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 9 [3pts possible]:
Display the title and running time for all TV specials ( titleType
= ''tvSpecial''
) from 1982; if the run time is
NULL, substitute zero.
---------------------------------------------------------------------------
-------
------------
Columns to display: title_basics.primaryTitle,
title_basics.runtimeMinutes
Sort in descending numerical order by the resulting calculated
run time value.' +
CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 10 [3pts possible]:
Identify every movie from 1913 (startYear = 1913, titleType =
''movie''); limit
your results to those with a non-NULL value
in the runtimeMinutescolumn. For each movie, display the
primaryTitle and the
averageRating value from the title_ratings table.
Use DENSE_RANK() to display the rank based on
averageRating (label this
RATINGRANK), and also the rank based on runtimeMinutes
(label this LENGTHRANK). Both of these should be based on
an asecending sort
order.
---------------------------------------------------------------------------
-------
------------
Columns to display: title_basics.primaryTitle,
title_ratings.averageRating,
RATINGRANK, LENGTHRANK
Sort results in ascending order by primaryTitle.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
---------------------------------------------------------------------------
-------
---
-- This is an anonymous program block. DO NOT CHANGE OR
DELETE.
---------------------------------------------------------------------------
-------
---
BEGIN
PRINT '|---' + REPLICATE('+----',15) + '|';
PRINT ' End of CIS275 Lab Week 6' + REPLICATE(' ',50) +
CONVERT(CHAR(12),GETDATE(),101);
PRINT '|---' + REPLICATE('+----',15) + '|';
END;
/*
*****************************************************
**************************************
CIS275 at PCC
CIS275 Lab Week 6: using SQL SERVER 2012 and the IMDB
database
*****************************************************
**************************************
CERTIFICATION:
By typing my name below I certify that the enclosed is
original coding written by myself
without unauthorized assistance. I agree to abide by class
restrictions and understand that
if I have violated them, I may receive reduced credit (or none)
for this assignment.
CONSENT: [your name here]
DATE: [date]
*****************************************************
**************************************
*/
USE IMDB -- ensures correct database is active
GO
PRINT '|---' + REPLICATE('+----',15) + '|'
PRINT 'Read the questions below and insert your queries where
prompted. When you are finished,
you should be able to run the file as a script to execute all
answers sequentially (without errors!)' + CHAR(10)
PRINT 'Queries should be well-formatted. SQL is not case-
sensitive, but it is good form to
capitalize keywords and table names; you should also put each
projected column on its own line
and use indentation for neatness. Example:
SELECT Name,
CustomerID
FROM CUSTOMER
WHERE CustomerID < 106;
All SQL statements should end in a semicolon. Whatever
format you choose for your queries, make
sure that it is readable and consistent.' + CHAR(10)
PRINT 'Be sure to remove the double-dash comment indicator
when you insert your code!';
PRINT '|---' + REPLICATE('+----',15) + '|' + CHAR(10) +
CHAR(10)
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 1 [3pts possible]:
Write the query to display the name and year of birth for all
people born after 1980, who have
directed at least one show (i.e. those who appear at least once in
the title_directors table).
Limit results to those who have died (who have a value in the
deathYear column).
---------------------------------------------------------------------------
-------------------
Columns to display: name_basics.primaryName,
name_basics.birthYear
Sort in descending order by birth year.' + CHAR(10)
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 2 [3pts possible]:
Show every genre of television show which has had at least one
title with 500 episodes.
i.e. limit results to the titleType ''tvEpisode'' in the title_basics
table, and to titles
containing a row in the title_episode table with episodeNumber
500.
---------------------------------------------------------------------------
-------------------
Columns to display: title_genre.genre
Display genre name only, and eliminate duplicate values.' +
CHAR(10)
GO
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 3 [3pts possible]:
Write a common table expression to identify the WORST shows:
join title_basics against title_ratings
and limit your results to those with an averageRating value
equal to 1. Project the title,
type, and startYear from title_basics; and label your CTE as
BADSHOWS.
In the main query, show a breakdown of BADSHOWS grouped
by type, along with the total number of
rows for each (i.e. GROUP BY titleType)
---------------------------------------------------------------------------
-------------------
Columns to display: titleType, COUNT(*)
Sort results in descending order by COUNT(*).' + CHAR(10)
GO
--
-- [Insert your code here]
--
GO
PRINT 'CIS2275, Lab Week 6, Question 4 [3pts possible]:
Identify the least popular professions. Show each profession
value from the name_profession table,
along with the total number of matching rows (GROUP BY
profession). Use the HAVING clause to limit
your results to professions with less than 1,000 rows.
---------------------------------------------------------------------------
-------------------
Columns to display: name_profession.profession, COUNT(*)'
+ CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 5 [3pts possible]:
Use the query from #4 above to display the names of all people
belonging to these professions.
Use the previous query as a subquery in the FROM clause here
to limit the results.
---------------------------------------------------------------------------
-------------------
Columns to display: name_basics.primaryName,
name_profession.profession
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 6 [3pts possible]:
Show the name of every writer, along with the total number of
titles they''ve written (i.e. rows in the
title_writers table). Limit results to those who have written
between 5,000 and 10,000 titles (inclusive).
---------------------------------------------------------------------------
-------------------
Columns to display: name_basics.primaryName, COUNT(*)
Sort results in descending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 7 [3pts possible]:
Show the actor and character names for everyone who has
performed the same role in more than one
show with the title ''Battlestar Galactica''. i.e. identify the
combination of (primaryName, characters)
which occurs in the title_principals table more than once for
matching titles.
---------------------------------------------------------------------------
-------------------
Columns to display: name_basics.primaryName,
title_principals.characters, COUNT(*)
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 8 [3pts possible]:
Identify the names of people who have directed more than five
highest-rated shows (i.e. title_ratings.averageRating = 10).
For each of these people, display their names and the total
number of shows they have written.
---------------------------------------------------------------------------
-------------------
Columns to display: name_basics.primaryName, COUNT(*)
Sort results in ascending order by primaryName.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 9 [3pts possible]:
Display the title and running time for all TV specials ( titleType
= ''tvSpecial'' ) from 1982; if the run time is
NULL, substitute zero.
---------------------------------------------------------------------------
-------------------
Columns to display: title_basics.primaryTitle,
title_basics.runtimeMinutes
Sort in descending numerical order by the resulting calculated
run time value.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
PRINT 'CIS2275, Lab Week 6, Question 10 [3pts possible]:
Identify every movie from 1913 (startYear = 1913, titleType =
''movie''); limit your results to those with a non-NULL value
in the runtimeMinutescolumn. For each movie, display the
primaryTitle and the averageRating value from the title_ratings
table.
Use DENSE_RANK() to display the rank based on
averageRating (label this RATINGRANK), and also the rank
based on runtimeMinutes
(label this LENGTHRANK). Both of these should be based on
an asecending sort order.
---------------------------------------------------------------------------
-------------------
Columns to display: title_basics.primaryTitle,
title_ratings.averageRating,
RATINGRANK, LENGTHRANK
Sort results in ascending order by primaryTitle.' + CHAR(10)
--
-- [Insert your code here]
--
GO
GO
---------------------------------------------------------------------------
----------
-- This is an anonymous program block. DO NOT CHANGE OR
DELETE.
---------------------------------------------------------------------------
----------
BEGIN
PRINT '|---' + REPLICATE('+----',15) + '|';
PRINT ' End of CIS275 Lab Week 6' + REPLICATE(' ',50) +
CONVERT(CHAR(12),GETDATE(),101);
PRINT '|---' + REPLICATE('+----',15) + '|';
END;

More Related Content

Similar to USE IMDB -- ensures correct database is active G.docx

Similar to USE IMDB -- ensures correct database is active G.docx (20)

Mysql
MysqlMysql
Mysql
 
Les01 Writing Basic Sql Statements
Les01 Writing Basic Sql StatementsLes01 Writing Basic Sql Statements
Les01 Writing Basic Sql Statements
 
Intro to SQL by Google's Software Engineer
Intro to SQL by Google's Software EngineerIntro to SQL by Google's Software Engineer
Intro to SQL by Google's Software Engineer
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application Development
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
 
Les01
Les01Les01
Les01
 
Les01
Les01Les01
Les01
 
SQL
SQLSQL
SQL
 
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
 
SQL
SQLSQL
SQL
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 
75864 sql
75864 sql75864 sql
75864 sql
 
SQLQueries
SQLQueriesSQLQueries
SQLQueries
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Sql
SqlSql
Sql
 
SQL sheet
SQL sheetSQL sheet
SQL sheet
 
Apache Cassandra, part 3 – machinery, work with Cassandra
Apache Cassandra, part 3 – machinery, work with CassandraApache Cassandra, part 3 – machinery, work with Cassandra
Apache Cassandra, part 3 – machinery, work with Cassandra
 
Cassandra, web scale no sql data platform
Cassandra, web scale no sql data platformCassandra, web scale no sql data platform
Cassandra, web scale no sql data platform
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
May Woo Bi Portfolio
May Woo Bi PortfolioMay Woo Bi Portfolio
May Woo Bi Portfolio
 

More from madlynplamondon

. According to your textbook, Contrary to a popular misconception.docx
. According to your textbook, Contrary to a popular misconception.docx. According to your textbook, Contrary to a popular misconception.docx
. According to your textbook, Contrary to a popular misconception.docxmadlynplamondon
 
-How did artwork produced in America from 1945 to 1960 compare to ar.docx
-How did artwork produced in America from 1945 to 1960 compare to ar.docx-How did artwork produced in America from 1945 to 1960 compare to ar.docx
-How did artwork produced in America from 1945 to 1960 compare to ar.docxmadlynplamondon
 
-Just thoughts and opinion on the reading-Consent and compen.docx
-Just thoughts and opinion on the reading-Consent and compen.docx-Just thoughts and opinion on the reading-Consent and compen.docx
-Just thoughts and opinion on the reading-Consent and compen.docxmadlynplamondon
 
. The Questioned Documents Unit (QDU) provides forensic support .docx
. The Questioned Documents Unit (QDU) provides forensic support .docx. The Questioned Documents Unit (QDU) provides forensic support .docx
. The Questioned Documents Unit (QDU) provides forensic support .docxmadlynplamondon
 
.  What is it about the fundamental nature and structure of the Olym.docx
.  What is it about the fundamental nature and structure of the Olym.docx.  What is it about the fundamental nature and structure of the Olym.docx
.  What is it about the fundamental nature and structure of the Olym.docxmadlynplamondon
 
-Learning objectives for presentation-Brief background o.docx
-Learning objectives for presentation-Brief background o.docx-Learning objectives for presentation-Brief background o.docx
-Learning objectives for presentation-Brief background o.docxmadlynplamondon
 
-You will need to play a phone game Angry Birds (any version) to mak.docx
-You will need to play a phone game Angry Birds (any version) to mak.docx-You will need to play a phone game Angry Birds (any version) to mak.docx
-You will need to play a phone game Angry Birds (any version) to mak.docxmadlynplamondon
 
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docxmadlynplamondon
 
. What were the causes of World War II Explain how and why the Unit.docx
. What were the causes of World War II Explain how and why the Unit.docx. What were the causes of World War II Explain how and why the Unit.docx
. What were the causes of World War II Explain how and why the Unit.docxmadlynplamondon
 
. Complete the prewriting for the progress reportPrewriting p.docx
. Complete the prewriting for the progress reportPrewriting p.docx. Complete the prewriting for the progress reportPrewriting p.docx
. Complete the prewriting for the progress reportPrewriting p.docxmadlynplamondon
 
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docxmadlynplamondon
 
-Write about a violent religious event in history.(Ex. Muslim ex.docx
-Write about a violent religious event in history.(Ex. Muslim ex.docx-Write about a violent religious event in history.(Ex. Muslim ex.docx
-Write about a violent religious event in history.(Ex. Muslim ex.docxmadlynplamondon
 
-This project is an opportunity to demonstrate the ability to analyz.docx
-This project is an opportunity to demonstrate the ability to analyz.docx-This project is an opportunity to demonstrate the ability to analyz.docx
-This project is an opportunity to demonstrate the ability to analyz.docxmadlynplamondon
 
-7 Three men are trapped in a cave with no hope of rescue and no foo.docx
-7 Three men are trapped in a cave with no hope of rescue and no foo.docx-7 Three men are trapped in a cave with no hope of rescue and no foo.docx
-7 Three men are trapped in a cave with no hope of rescue and no foo.docxmadlynplamondon
 
-1. Are the three main elements of compensation systems—internal.docx
-1. Are the three main elements of compensation systems—internal.docx-1. Are the three main elements of compensation systems—internal.docx
-1. Are the three main elements of compensation systems—internal.docxmadlynplamondon
 
- What are the key differences between national health service (.docx
- What are the key differences between national health service (.docx- What are the key differences between national health service (.docx
- What are the key differences between national health service (.docxmadlynplamondon
 
--Describe and analyze the ways in which Alfons Heck’s participation.docx
--Describe and analyze the ways in which Alfons Heck’s participation.docx--Describe and analyze the ways in which Alfons Heck’s participation.docx
--Describe and analyze the ways in which Alfons Heck’s participation.docxmadlynplamondon
 
------ Watch an online speechpresentation of 20 minutes or lo.docx
------ Watch an online speechpresentation of 20 minutes or lo.docx------ Watch an online speechpresentation of 20 minutes or lo.docx
------ Watch an online speechpresentation of 20 minutes or lo.docxmadlynplamondon
 
) Florida National UniversityNursing DepartmentBSN.docx
) Florida National UniversityNursing DepartmentBSN.docx) Florida National UniversityNursing DepartmentBSN.docx
) Florida National UniversityNursing DepartmentBSN.docxmadlynplamondon
 
- Please answer question 2 at the end of the case.- cita.docx
- Please answer question 2 at the end of the case.- cita.docx- Please answer question 2 at the end of the case.- cita.docx
- Please answer question 2 at the end of the case.- cita.docxmadlynplamondon
 

More from madlynplamondon (20)

. According to your textbook, Contrary to a popular misconception.docx
. According to your textbook, Contrary to a popular misconception.docx. According to your textbook, Contrary to a popular misconception.docx
. According to your textbook, Contrary to a popular misconception.docx
 
-How did artwork produced in America from 1945 to 1960 compare to ar.docx
-How did artwork produced in America from 1945 to 1960 compare to ar.docx-How did artwork produced in America from 1945 to 1960 compare to ar.docx
-How did artwork produced in America from 1945 to 1960 compare to ar.docx
 
-Just thoughts and opinion on the reading-Consent and compen.docx
-Just thoughts and opinion on the reading-Consent and compen.docx-Just thoughts and opinion on the reading-Consent and compen.docx
-Just thoughts and opinion on the reading-Consent and compen.docx
 
. The Questioned Documents Unit (QDU) provides forensic support .docx
. The Questioned Documents Unit (QDU) provides forensic support .docx. The Questioned Documents Unit (QDU) provides forensic support .docx
. The Questioned Documents Unit (QDU) provides forensic support .docx
 
.  What is it about the fundamental nature and structure of the Olym.docx
.  What is it about the fundamental nature and structure of the Olym.docx.  What is it about the fundamental nature and structure of the Olym.docx
.  What is it about the fundamental nature and structure of the Olym.docx
 
-Learning objectives for presentation-Brief background o.docx
-Learning objectives for presentation-Brief background o.docx-Learning objectives for presentation-Brief background o.docx
-Learning objectives for presentation-Brief background o.docx
 
-You will need to play a phone game Angry Birds (any version) to mak.docx
-You will need to play a phone game Angry Birds (any version) to mak.docx-You will need to play a phone game Angry Birds (any version) to mak.docx
-You will need to play a phone game Angry Birds (any version) to mak.docx
 
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx
. EDU 571 Week 5 Discussion 1 -Data Collection Please respond .docx
 
. What were the causes of World War II Explain how and why the Unit.docx
. What were the causes of World War II Explain how and why the Unit.docx. What were the causes of World War II Explain how and why the Unit.docx
. What were the causes of World War II Explain how and why the Unit.docx
 
. Complete the prewriting for the progress reportPrewriting p.docx
. Complete the prewriting for the progress reportPrewriting p.docx. Complete the prewriting for the progress reportPrewriting p.docx
. Complete the prewriting for the progress reportPrewriting p.docx
 
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx
-in Filomena by Roberta Fernandez the author refers to the Mexican r.docx
 
-Write about a violent religious event in history.(Ex. Muslim ex.docx
-Write about a violent religious event in history.(Ex. Muslim ex.docx-Write about a violent religious event in history.(Ex. Muslim ex.docx
-Write about a violent religious event in history.(Ex. Muslim ex.docx
 
-This project is an opportunity to demonstrate the ability to analyz.docx
-This project is an opportunity to demonstrate the ability to analyz.docx-This project is an opportunity to demonstrate the ability to analyz.docx
-This project is an opportunity to demonstrate the ability to analyz.docx
 
-7 Three men are trapped in a cave with no hope of rescue and no foo.docx
-7 Three men are trapped in a cave with no hope of rescue and no foo.docx-7 Three men are trapped in a cave with no hope of rescue and no foo.docx
-7 Three men are trapped in a cave with no hope of rescue and no foo.docx
 
-1. Are the three main elements of compensation systems—internal.docx
-1. Are the three main elements of compensation systems—internal.docx-1. Are the three main elements of compensation systems—internal.docx
-1. Are the three main elements of compensation systems—internal.docx
 
- What are the key differences between national health service (.docx
- What are the key differences between national health service (.docx- What are the key differences between national health service (.docx
- What are the key differences between national health service (.docx
 
--Describe and analyze the ways in which Alfons Heck’s participation.docx
--Describe and analyze the ways in which Alfons Heck’s participation.docx--Describe and analyze the ways in which Alfons Heck’s participation.docx
--Describe and analyze the ways in which Alfons Heck’s participation.docx
 
------ Watch an online speechpresentation of 20 minutes or lo.docx
------ Watch an online speechpresentation of 20 minutes or lo.docx------ Watch an online speechpresentation of 20 minutes or lo.docx
------ Watch an online speechpresentation of 20 minutes or lo.docx
 
) Florida National UniversityNursing DepartmentBSN.docx
) Florida National UniversityNursing DepartmentBSN.docx) Florida National UniversityNursing DepartmentBSN.docx
) Florida National UniversityNursing DepartmentBSN.docx
 
- Please answer question 2 at the end of the case.- cita.docx
- Please answer question 2 at the end of the case.- cita.docx- Please answer question 2 at the end of the case.- cita.docx
- Please answer question 2 at the end of the case.- cita.docx
 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

USE IMDB -- ensures correct database is active G.docx

  • 1. USE IMDB -- ensures correct database is active GO PRINT '|---' + REPLICATE('+----',15) + '|' PRINT 'Read the questions below and insert your queries where prompted. When you are finished, you should be able to run the file as a script to execute all answers sequentially (without errors!)' + CHAR(10) PRINT 'Queries should be well-formatted. SQL is not case- sensitive, but it is good form to capitalize keywords and table names; you should also put each projected column on its own line and use indentation for neatness. Example: SELECT Name, CustomerID FROM CUSTOMER WHERE CustomerID < 106; All SQL statements should end in a semicolon. Whatever format you choose for your queries, make sure that it is readable and consistent.' + CHAR(10) PRINT 'Be sure to remove the double-dash comment indicator when you insert your code!';
  • 2. PRINT '|---' + REPLICATE('+----',15) + '|' + CHAR(10) + CHAR(10) GO GO PRINT 'CIS2275, Lab Week 6, Question 1 [3pts possible]: Write the query to display the name and year of birth for all people born after 1980, who have directed at least one show (i.e. those who appear at least once in the title_directors table). Limit results to those who have died (who have a value in the deathYear column). --------------------------------------------------------------------------- ------- ------------ Columns to display: name_basics.primaryName, name_basics.birthYear Sort in descending order by birth year.' + CHAR(10) -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 2 [3pts possible]: Show every genre of television show which has had at least one title with 500 episodes. i.e. limit results to the titleType ''tvEpisode'' in the title_basics table, and to titles containing a row in the title_episode table with episodeNumber 500.
  • 3. --------------------------------------------------------------------------- ------- ------------ Columns to display: title_genre.genre Display genre name only, and eliminate duplicate values.' + CHAR(10) GO -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 3 [3pts possible]: Write a common table expression to identify the WORST shows: join title_basics against title_ratings and limit your results to those with an averageRating value equal to 1. Project the title, type, and startYear from title_basics; and label your CTE as BADSHOWS. In the main query, show a breakdown of BADSHOWS grouped by type, along with the total number of rows for each (i.e. GROUP BY titleType) --------------------------------------------------------------------------- ------- ------------ Columns to display: titleType, COUNT(*) Sort results in descending order by COUNT(*).' + CHAR(10)
  • 4. GO -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 4 [3pts possible]: Identify the least popular professions. Show each profession value from the name_profession table, along with the total number of matching rows (GROUP BY profession). Use the HAVING clause to limit your results to professions with less than 1,000 rows. --------------------------------------------------------------------------- ------- ------------ Columns to display: name_profession.profession, COUNT(*)' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 5 [3pts possible]: Use the query from #4 above to display the names of all people belonging to these professions. Use the previous query as a subquery in the FROM clause here to limit the results. ---------------------------------------------------------------------------
  • 5. ------- ------------ Columns to display: name_basics.primaryName, name_profession.profession Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 6 [3pts possible]: Show the name of every writer, along with the total number of titles they''ve written (i.e. rows in the title_writers table). Limit results to those who have written between 5,000 and 10,000 titles (inclusive). --------------------------------------------------------------------------- ------- ------------ Columns to display: name_basics.primaryName, COUNT(*) Sort results in descending order by primaryName.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 7 [3pts possible]: Show the actor and character names for everyone who has
  • 6. performed the same role in more than one show with the title ''Battlestar Galactica''. i.e. identify the combination of (primaryName, characters) which occurs in the title_principals table more than once for matching titles. --------------------------------------------------------------------------- ------- ------------ Columns to display: name_basics.primaryName, title_principals.characters, COUNT(*) Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 8 [3pts possible]: Identify the names of people who have directed more than five highest-rated shows (i.e. title_ratings.averageRating = 10). For each of these people, display their names and the total number of shows they have written. --------------------------------------------------------------------------- ------- ------------ Columns to display: name_basics.primaryName, COUNT(*) Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] --
  • 7. GO GO PRINT 'CIS2275, Lab Week 6, Question 9 [3pts possible]: Display the title and running time for all TV specials ( titleType = ''tvSpecial'' ) from 1982; if the run time is NULL, substitute zero. --------------------------------------------------------------------------- ------- ------------ Columns to display: title_basics.primaryTitle, title_basics.runtimeMinutes Sort in descending numerical order by the resulting calculated run time value.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 10 [3pts possible]: Identify every movie from 1913 (startYear = 1913, titleType = ''movie''); limit your results to those with a non-NULL value in the runtimeMinutescolumn. For each movie, display the primaryTitle and the averageRating value from the title_ratings table. Use DENSE_RANK() to display the rank based on averageRating (label this
  • 8. RATINGRANK), and also the rank based on runtimeMinutes (label this LENGTHRANK). Both of these should be based on an asecending sort order. --------------------------------------------------------------------------- ------- ------------ Columns to display: title_basics.primaryTitle, title_ratings.averageRating, RATINGRANK, LENGTHRANK Sort results in ascending order by primaryTitle.' + CHAR(10) -- -- [Insert your code here] -- GO GO --------------------------------------------------------------------------- ------- --- -- This is an anonymous program block. DO NOT CHANGE OR DELETE. --------------------------------------------------------------------------- ------- --- BEGIN PRINT '|---' + REPLICATE('+----',15) + '|'; PRINT ' End of CIS275 Lab Week 6' + REPLICATE(' ',50) + CONVERT(CHAR(12),GETDATE(),101); PRINT '|---' + REPLICATE('+----',15) + '|'; END;
  • 9. /* ***************************************************** ************************************** CIS275 at PCC CIS275 Lab Week 6: using SQL SERVER 2012 and the IMDB database ***************************************************** ************************************** CERTIFICATION: By typing my name below I certify that the enclosed is original coding written by myself without unauthorized assistance. I agree to abide by class restrictions and understand that if I have violated them, I may receive reduced credit (or none) for this assignment. CONSENT: [your name here] DATE: [date]
  • 10. ***************************************************** ************************************** */ USE IMDB -- ensures correct database is active GO PRINT '|---' + REPLICATE('+----',15) + '|' PRINT 'Read the questions below and insert your queries where prompted. When you are finished, you should be able to run the file as a script to execute all answers sequentially (without errors!)' + CHAR(10) PRINT 'Queries should be well-formatted. SQL is not case- sensitive, but it is good form to capitalize keywords and table names; you should also put each projected column on its own line and use indentation for neatness. Example:
  • 11. SELECT Name, CustomerID FROM CUSTOMER WHERE CustomerID < 106; All SQL statements should end in a semicolon. Whatever format you choose for your queries, make sure that it is readable and consistent.' + CHAR(10) PRINT 'Be sure to remove the double-dash comment indicator when you insert your code!'; PRINT '|---' + REPLICATE('+----',15) + '|' + CHAR(10) + CHAR(10) GO GO PRINT 'CIS2275, Lab Week 6, Question 1 [3pts possible]: Write the query to display the name and year of birth for all people born after 1980, who have directed at least one show (i.e. those who appear at least once in the title_directors table).
  • 12. Limit results to those who have died (who have a value in the deathYear column). --------------------------------------------------------------------------- ------------------- Columns to display: name_basics.primaryName, name_basics.birthYear Sort in descending order by birth year.' + CHAR(10) -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 2 [3pts possible]: Show every genre of television show which has had at least one title with 500 episodes. i.e. limit results to the titleType ''tvEpisode'' in the title_basics table, and to titles containing a row in the title_episode table with episodeNumber 500. ---------------------------------------------------------------------------
  • 13. ------------------- Columns to display: title_genre.genre Display genre name only, and eliminate duplicate values.' + CHAR(10) GO -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 3 [3pts possible]: Write a common table expression to identify the WORST shows: join title_basics against title_ratings and limit your results to those with an averageRating value equal to 1. Project the title, type, and startYear from title_basics; and label your CTE as BADSHOWS.
  • 14. In the main query, show a breakdown of BADSHOWS grouped by type, along with the total number of rows for each (i.e. GROUP BY titleType) --------------------------------------------------------------------------- ------------------- Columns to display: titleType, COUNT(*) Sort results in descending order by COUNT(*).' + CHAR(10) GO -- -- [Insert your code here] -- GO PRINT 'CIS2275, Lab Week 6, Question 4 [3pts possible]: Identify the least popular professions. Show each profession value from the name_profession table, along with the total number of matching rows (GROUP BY
  • 15. profession). Use the HAVING clause to limit your results to professions with less than 1,000 rows. --------------------------------------------------------------------------- ------------------- Columns to display: name_profession.profession, COUNT(*)' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 5 [3pts possible]: Use the query from #4 above to display the names of all people belonging to these professions. Use the previous query as a subquery in the FROM clause here to limit the results. --------------------------------------------------------------------------- ------------------- Columns to display: name_basics.primaryName,
  • 16. name_profession.profession Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 6 [3pts possible]: Show the name of every writer, along with the total number of titles they''ve written (i.e. rows in the title_writers table). Limit results to those who have written between 5,000 and 10,000 titles (inclusive). --------------------------------------------------------------------------- ------------------- Columns to display: name_basics.primaryName, COUNT(*) Sort results in descending order by primaryName.' + CHAR(10) -- -- [Insert your code here]
  • 17. -- GO GO PRINT 'CIS2275, Lab Week 6, Question 7 [3pts possible]: Show the actor and character names for everyone who has performed the same role in more than one show with the title ''Battlestar Galactica''. i.e. identify the combination of (primaryName, characters) which occurs in the title_principals table more than once for matching titles. --------------------------------------------------------------------------- ------------------- Columns to display: name_basics.primaryName, title_principals.characters, COUNT(*) Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] --
  • 18. GO GO PRINT 'CIS2275, Lab Week 6, Question 8 [3pts possible]: Identify the names of people who have directed more than five highest-rated shows (i.e. title_ratings.averageRating = 10). For each of these people, display their names and the total number of shows they have written. --------------------------------------------------------------------------- ------------------- Columns to display: name_basics.primaryName, COUNT(*) Sort results in ascending order by primaryName.' + CHAR(10) -- -- [Insert your code here] -- GO GO
  • 19. PRINT 'CIS2275, Lab Week 6, Question 9 [3pts possible]: Display the title and running time for all TV specials ( titleType = ''tvSpecial'' ) from 1982; if the run time is NULL, substitute zero. --------------------------------------------------------------------------- ------------------- Columns to display: title_basics.primaryTitle, title_basics.runtimeMinutes Sort in descending numerical order by the resulting calculated run time value.' + CHAR(10) -- -- [Insert your code here] -- GO GO PRINT 'CIS2275, Lab Week 6, Question 10 [3pts possible]: Identify every movie from 1913 (startYear = 1913, titleType = ''movie''); limit your results to those with a non-NULL value
  • 20. in the runtimeMinutescolumn. For each movie, display the primaryTitle and the averageRating value from the title_ratings table. Use DENSE_RANK() to display the rank based on averageRating (label this RATINGRANK), and also the rank based on runtimeMinutes (label this LENGTHRANK). Both of these should be based on an asecending sort order. --------------------------------------------------------------------------- ------------------- Columns to display: title_basics.primaryTitle, title_ratings.averageRating, RATINGRANK, LENGTHRANK Sort results in ascending order by primaryTitle.' + CHAR(10) -- -- [Insert your code here] -- GO GO
  • 21. --------------------------------------------------------------------------- ---------- -- This is an anonymous program block. DO NOT CHANGE OR DELETE. --------------------------------------------------------------------------- ---------- BEGIN PRINT '|---' + REPLICATE('+----',15) + '|'; PRINT ' End of CIS275 Lab Week 6' + REPLICATE(' ',50) + CONVERT(CHAR(12),GETDATE(),101); PRINT '|---' + REPLICATE('+----',15) + '|'; END;