Working with the correct data types
It’s now time to practice your understanding of various data types in SQL Server and how to convert them from one type to another.
In this exercise, you will query the voters
table. Remember that this table holds information about the people who provided ratings for the different chocolate flavors.
You are going to write a query that returns information (first name, last name, gender, country, number of times they voted) about the female voters from Belgium, who voted more than 20 times.
You will work with columns of different data types and perform both implicit and explicit conversions between different types of data (using CAST()
and CONVERT()
functions).
It sounds like a big query, but we will take it step-by-step and you will see the results in no time!
This exercise is part of the course
Functions for Manipulating Data in SQL Server
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
first_name,
last_name,
gender,
country
FROM voters
WHERE country = 'Belgium'
-- Select only the female voters
AND ___
-- Select only people who voted more than 20 times
AND ___;