Get Started

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”

View Course

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;

This exercise is part of the course

Introduction to SQL Server

BeginnerSkill Level
4.3+
56 reviews

Learn to use SQL Server to perform common data manipulation tasks and master common data manipulation tasks using this database system.

Hit the ground running by learning the basics of SELECT statements to retrieve data from one or more columns. You'll also learn how to apply filters to both numeric and text data, and sort the results.

Exercise 1: WelcomeExercise 2: Simple selectionsExercise 3: More selectionsExercise 4: Ordering and filteringExercise 5: Order byExercise 6: WhereExercise 7: Where againExercise 8: Working with NULL valuesExercise 9: WHERE the wild things areExercise 10: Exploring classic rock songsExercise 11: Exploring classic rock songs - AND/ORExercise 12: Using parentheses in your queries

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free