SQL Functions for Data Analysis

Home/SQL/SQL Functions for Data Analysis

Functions are a very powerful feature of SQL and can be used to do the following:



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

  • Perform calculations on data
  • Modify individual data items
  • Manipulate output for groups of rows
  • Format dates and numbers for display
  • Convert column data types

–SQL functions sometimes take arguments and always return a value.

Types of SQL function for performing calculations on data are:

  • Arithmetic Functions
  • Aggregate Functions
  • Scalar Functions

SQL functions help to aggregate the data while extracting the data from Data base. There are many functions available in SQL to aggregate the data to analyse it.

Arithmetic Functions

Arithmetic Functions are used to perform calculations in SQL, the valid symbols are +-*/() .


[code lanuage=”sql”] SELECT EID, (SALARY/12) GROSS_SALARY FROM EMPLOYEE WHERE Department= ‘HR’ ;

Scalar Functions

SQL scalar functions return a single value, based on the input value. Various Scalar functions include: CHAR, DATE, DAY(S), DECIMAL, DIGITS, FLOAT, HEX, HOUR, INTEGER, LENGTH, MICROSECOND, MINUTE, MONTH, SECOND, SUBSTR, TIME.


[code lanuage=”sql”] SELECT Name, SUBSTRING(Name, 1, 1) AS Initial FROM Employee;


SQL aggregate functions return a single value, calculated from values in a column. Various aggregate functions are:AVG,COUNT,MAX,MIN,SUM.


[code lanuage=”sql”] SELECT AVG(SALARY) AVG-SAL FROM Employee WHERE Department= ‘Research’;

Frequently Used Functions

SQL has many built-in functions for performing processing on string or numeric data. Following is the list of all useful SQL built-in functions:

  • COUNT Function – The SQL COUNT aggregate function is used to count the number of rows in a database table.
  • MAX Function – The SQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.
  • MIN Function – The SQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.
  • AVG Function – The SQL AVG aggregate function selects the average value for certain table column.
  • SUM Function – The SQL SUM aggregate function allows selecting the total for a numeric column.
  • SQRT Functions – This is used to generate a square root of a given number.
  • RAND Function – This is used to generate a random number using SQL command.
  • SQL CONCAT Function – This is used to concatenate any string inside any SQL command.
By |June 15th, 2013|SQL|0 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

Leave A Comment

Related pages

how to enable macros in excel sheetaccess vba insert into table from formlooking for duplicates in excelsoftware project plan template excelcalculate difference between two dates in excelvba get file extensionexcel shortcut chartvba import data from another workbookvb copy filevba excel advanced filtervba conditionvba xlusing pivot in excelexcel vba data typehow to protect workbook in excel 2007dashboard creation in excelinsert a column in excelvb code to open a fileto find duplicate records in exceladvanced excel charts and graphsbox plot excel 2010 templateadvanced functions of exceloffset function excel 2013vba odbcunlock excel workbook passwordvba update queryexcel 2010 nested if statementsexcel unlock cellssql interview question for fresherhide column exceldbms interview questions and answers pdfhow to lock an excel spreadsheetusing functions in vbaexcel chart objectvlookup in excel 2007 with example in excelvba create a new worksheetchart tools layout tabexcel vba tutorialsexcel vba checkbox checkedreturn vbaexcel project budget templatevba sql insertmultiple stacked bar chart excel 2010excel isblankvba sort excelplot chart excelmerge and center excel 2010interior.color vbaspecial characters in excel formulassample vbscript codevba excel fileformatsimple project charter template freeexcel vba refreshvba excel modworksheet name in vbaunprotect sheet excelexcel formula sumifexcel 2010 unhide columnsexcel macros buttonusing excel vba to run sql queryexcel 2010 merge cellshow to merge cells excel 2010macros in excel 2007vba exit formnested if and statements in excel 2010how to do drop down list in excel 2007vba run applicationauto column width excelsimple cut and paste worksheetshow to unlock an excel spreadsheet without the passwordprotect formulas in excel 2007delete named range excelexcel 2003 autosaveexcel macro counthow to find duplicate records in excelexcel unprotect sheet password removerhow to remove duplicates from exceldisable excel macrosexcel connect to mysqlvlookup if isnaexcel password protected file forgot password