From the course: SQL Server 2008 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Using aggregate functions

Using aggregate functions - SQL Server Tutorial

From the course: SQL Server 2008 Essential Training

Start my 1-month free trial

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…

Contents