Winners table in the Oscars.mdf database Name Data Type Allow Nulls Default o Year int Actor varchar(50) Actiess varchar(50) Picture varchar(50) Animated varchar(50) Year Actor Actress Picture Animated 2008 2009 Danicl Day-Lewis Marion Cotillard No Country for Old Men Ratatouille Scon Penn Kete Winslet Slumdog Millioneire WALL-E 2010 Jeff Bridges Sandra Bullock The Hurt Locker Up 2011 Colin Firth Natalie Portman The King's Speech Toy Story 3 2012 2013 2014 Jean Dujardin Meryl Streep The Artist Rango Danid-Day Lewis Jennifer Lawrence Argo Brave Matthew McConaughey Cate Blanchett Eddie Redmayne 12 Vears a Slave Frozen 2015 Julianne Moore Birdman Big Hero 6 2016 2017 Leonardo DiCaprio Brie Larson Spotlight Inside Out Casey Affleck Emma Stone Moonlight Zoctopia Example 1 SELECT Year, Actor, Actress, Picture, Animated FROM Winners selects all of the fields and records from the table Example 2 SELECT Year, Actor, Actress, Picture, Animated FROM Winners WHERE Year >= 2014 selects all of the fields from records for the year 2014 and later Example 3 SELECT Year FROM Winners WHERE Picture = 'Argo' selects the Year field for the Argo record (continued) Example 4 SELECT Year, Picture FROM Winners WHERE Picture LIKE 'The %' selects the Year and Picture fields for all records whose Picture field begins with the word "The" followed by a space and zero or more characters Example 5 SELECT Year, Animated FROM Winners WHERE Year = 2010 OR Year = 2015 ORDER BY Year DESC selects the Year and Animated fields for records whose Year field contains either 2010 or 2015 and then arranges the records in descending order by the Year field
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Using the Winners table from Figure 12-2, write a SELECT statement that selects only
the Animated field for records whose Animated field begins with the letter R. Sort the
records in ascending order by the Animated field.
Step by step
Solved in 2 steps