Using parentheses in your queries
You can use parentheses to make the intention of your code clearer. This becomes very important when using AND and OR clauses, to ensure your queries return the exact subsets you need.
This is a part of the course
“Introduction to SQL Server”
Exercise instructions
Select all artists beginning with B
who released tracks in 1986
, but also retrieve any records where the release_year
is greater than 1990
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
artist,
release_year,
song
FROM
songlist
-- Choose the correct artist and specify the release year
WHERE
(
artist LIKE 'B%'
___ release_year = ___
)
-- Or return all songs released after 1990
___ release_year ___ ___
-- Order the results
ORDER BY
release_year,
artist,
song;