Aggregate Functions in SQL SERVER 2008

What are Aggregate functions? Explain Aggregate functions in SQL SERVER 2008 with example.

Aggregate functions are applied to a group of data values from a column. Aggregate functions always return a single value.

SQL SERVER 2008 / Transact-SQL supports following aggregate functions:

AVG: Calculates the arithmetic mean (average) of the data values contained within a column. The column must contain numeric values.

MAX and MIN: Calculate the maximum and minimum data value of the column, respectively. The column can contain numeric, string, and date/time values.

SUM: Calculates the total of all data values in a column. The column must contain numeric values.

COUNT: Calculates the number of (non-null) data values in a column. The only aggregate function not being applied to columns is COUNT(*). This function returns the number of rows (whether or not particular columns have NULL values).

COUNT_BIG: New and Analogous to COUNT, the only difference being that COUNT_BIG returns a value of the BIGINT data type.

Aggregate function Example:
SELECT ProjectName, SUM(budget) TotalBudget FROM Project_Tbl GROUP BY ProjectName;


More Questions? Ask in comments.

9 comments:

  1. thanks for sharing ur knowledge

    http://soft-engineering.blogspot.com/

    ReplyDelete
  2. what is function in sql server 2008??

    ReplyDelete
  3. Nice questions
    http://www.interviewqsn.com
    http://www.getproductprice.com

    ReplyDelete
  4. I have found another nice post over the internet which is also having a wonderful explanation on sql server aggregate function or sql function. For more details of that post please check out this link...
    http://mindstick.com/Articles/485e31f2-613e-4758-8d4f-5a5d74c3a2ed/?%E2%80%98SELECT%E2%80%99%20command%20with%20Aggregate%20Function

    Thanks

    ReplyDelete
  5. Nice information you've provided in this blog. Very informative blog. I really enjoyed and got useful information.

    ReplyDelete
  6. I do nоt even know how I enԁed uρ here,
    but I thought thіѕ post ωas great. I don't know who you are but definitely you're going to a fаmous blogger
    іf you are not alrеady ;) Cheers!

    Here is my homepage Visit This Website

    ReplyDelete
  7. Hey!
    What a commendable work you have done, with simplest of language.I'm truly enjoying the design and layout of your site. I can’t resist myself to leave a comment and trust me it’s hard to impress me.

    Vachel
    PHP Development Chicago
    .NET Development Chicago
    Chicago Development Team
    cmscentral.net

    ReplyDelete
  8. Thank You! For sharing such a great article, It’s been an amazing article. It provides lot’s of information, I really enjoyed to read this, I hope, I will get these kinds of information on a regular basis from your side.

    Apps Development Companiesin Ghana

    ReplyDelete

Type more interview question answer here