From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Finding unique values - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
Finding unique values
Okay, next up is a fairly easy one. Let's say I have got a straightforward SQL statement here, just selecting star from SalesLT.Address, and I scan some of this information and see that I've got a lot of information such as different states and different countries and regions. And what I might be interested in this is this. I don't really care about the individual pieces of data, but I'd like to know, for example, what the different countries are that we ship to. Well, I could start off by just filtering this data down. Rather than SELECT *, I'll just say well, SELECT CountryRegion FROM SalesLT.Address and execute that. It still returns 450 rows that I could scan through, and it certainly doesn't look like there are too many countries, but just to be sure how could I start to ask for those individual values. I really just want to know it is Canada, the US, and whatever counties there are. Well, this is what I do. I use the word DISTINCT in the SELECT statement just before the actual…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Introduction to Transact-SQL3m 43s
-
(Locked)
Using SELECT statements7m 16s
-
(Locked)
Changing the default database2m 21s
-
(Locked)
Creating conditions in SQL8m 10s
-
(Locked)
Sorting your output3m 23s
-
(Locked)
Using aggregate functions7m 12s
-
(Locked)
Finding unique values2m 14s
-
(Locked)
Joining multiple tables together8m
-
(Locked)
Using subqueries9m 33s
-
(Locked)
Viewing execution plans3m 37s
-
(Locked)
-
-
-
-
-
-
-
-
-