From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using aggregate functions - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
Using aggregate functions
Next up, we have a few more keywords to work with an SQL and these would be grouped under the idea of something called aggregate functions, which is a fairly unpleasant name for a very useful piece. Now we've seen already how we can do a simple select statement like this, SELECT * FROM SalesLT.Product, and this returns everything. All our columns, all our rows and in fact, I can see it's 295 rows either by scrolling down to the bottom of the results or just reading it here in the status bar. But what if that was the piece of information I wanted? What if I just wanted to know the answer was 295? We have 295 products. I don't care about the rest of the data. Well, I can do that by using a piece of SQL called COUNT. And what I'm going to do is give it a little argument here, a little bit of information that says I want the count of everything. SELECT COUNT(*) FROM SalesLT.Product. Execute and it basically returns just that value, just 295. I can see that I don't have a column name for…
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)
-
-
-
-
-
-
-
-
-