Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> Database >> Aggregate functions in Database
Aggregate functions in Database

How use Aggregate Functions in database?
Views: 673     Comments: 0
by Amit Singh on 11/16/2010

Aggregate functions are applied to agroup of data values from a column. Aggregate functions always return a singlevalue.


How database supports following aggregate functions:
AVG: Calculates the arithmetic mean (average) of the data valuescontained within a column. The column must contain numeric values.

Syntax:

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

Syntax:

SELECT MAX(column_name) FROM table_name

SELECT MIN(column_name) FROM table_name
SUM: Calculates the total of all data values in a column. The columnmust contain numeric values.

Syntax:

SELECT SUM(column_name) FROM table_name
COUNT: Calculates the number of (non-null) data values in a column. Theonly aggregate function not being applied to columns is COUNT(*). This functionreturns the number of rows (whether or not particular columns have NULLvalues).

Syntax:

SELECT COUNT(column_name) FROM table_name
COUNT_BIG: New and Analogous to COUNT, the only difference being thatCOUNT_BIG returns a value of the BIGINT data type.

Syntax:

COUNT_BIG ( { [ ALL | DISTINCT ] expression } | * )

Aggregatefunction Example:

·        SELECT COUNT(*)FROM tblcheck

Output:
CountData

9

·        SELECT SUM(empid) AS SumData  FROM tblcheck

Output:

SumData

45

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Amit SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2632
  
Copyright © 2013MindStick. All Rights Reserved.