MVC

  • Home
  • HTML
    • Overview
    • Formatting
  • Java Script
    • Overview
    • Validation
  • CSS
    • Overview
  • Sql
    • Overview
    • SQL Select
    • SQL Command
    • Advance Query
    • SQL Create
    • Function
    • Function vs StoreProcedure
    • Stored Procedures
  • MVC
    • OverView
    • Evolution of MVC
    • Install VisualStudio-2015
    • Create First Application
  • LINQ
    • Introduction
  • Privacy Policy

Sunday, 5 March 2017

What is Function in Sql Server

  Unknown       08:38       Function       No comments    

A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in sql server.

We can define function like-
 User Define function - It is created by user and use in any query and SP also.
 System Define function- Most of the function define by System in SQL inbuilt function.

SQL Function

Scalar Functions

Scalar functions is a function where it is return a single value. Below is the list of some useful Sql Server Scalar functions. UCASE()
LCASE()
ABS()
RAND()
ROUND()
UPPER()
LOWER()
LTRIM()
LEN()
FORMAT()
NOW()

SQL Aggregate Function

SQL Aggregate functions return a single value, calculated from values in a column.
    AVG()
   COUNT()
   SUM()
   MAX()
   MIN()

Detail Discription as below with example

AVG() - This function returns the average value of a numeric column in SQL Server.
SELECT AVG(columnName) FROM TableName
Example
SELECT AVG(Salary) AS Salary FROM Customer

We Create a Table Customer Insert Some Column Table look like as below -



Created Table Customer and we apply AVG of Salary in Customer table then use AVG function and easily find avg of salary like-



Note- In This Example Salary is ColumnName and Customer is TableName Find Avg of salary in customer table and see output as below-


COUNT() - This function is used to count total number of value and return total row in SQL Server.

SQL COUNT() Syntax-

        SELECT COUNT(columnName) FROM TableName

Example
SELECT COUNT(Salary) AS Salary FROM Customer

Note- In This Example Salary is columnName and Customer is TableName Return total num of salary in customer table and see output as below-


SUM() - This function is used to sum total number of value of the selected column  SQL Server.

SQL SUM() Syntax-

    SELECT SUM(columnName) FROM TableName
Example
SELECT SUM(Salary) AS Salary FROM Customer

Note- In This Example Salary is ColumnName and Customer is TableName Return Total SUM of salary in customer table and see output as below-


MAX() - This function returns the Max or largest value of the selected column in SQL Server.

SQL MAX() Syntax-

        SELECT MAX(columnName) FROM TableName
Example
SELECT MAX(Salary) AS Salary FROM Customer

Note- In This Example Salary is ColumnName and Customer is TableName Return Maximum salary in customer table and see output as below-



MIN() - This function returns the Minimum value of the selected column in SQL Server.

SQL MIN() Syntax-

      SELECT MIN(columnName) FROM TableName
Example
SELECT MIN(Salary) AS Salary FROM Customer

Note - In This Example Salary is ColumnName and Customer is TableName Return Minimum or smallest salary in customer table and see output as below-


  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email This BlogThis! Share to X Share to Facebook
Newer Post Older Post Home

0 comments :

Post a Comment

learningmvctutorial

Popular Posts

  • Overview
      SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
  • Overview of HTML
    What is HTML? First developed by Tim Berners-Lee in 1990 . HTML is used to create electronic documents (called pages) that are displ...
  • Difference Between function v/s store procedure
    Definition  of Store Procedure In a database management system (DBMS), a  stored procedure  is a set of Structured Query Language (SQL...
  • SQL Select
    The SQL SELECT Statement The SELECT statement is used to select data from a database. SQL SELECT Syntax SELECT column_name , column_n...
  • What is LINQ
    LINQ  (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Mic...
  • What is Function in Sql Server
    A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in...
  • Create Duplicate Table of existing table in SQL Server
    In This Tutorial we create table and want to same structure and same data then We create new table with data type after that  insert in ta...
  • About Javascript
    What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
  • Operator in JavaScript
    What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
  • Open Application in MVC
    We want to create application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer and  I...

Blog Archive

  • ▼  2017 ( 35 )
    • ►  November ( 1 )
    • ►  October ( 2 )
    • ►  September ( 4 )
    • ►  August ( 1 )
    • ►  July ( 1 )
    • ►  May ( 3 )
    • ►  April ( 7 )
    • ▼  March ( 13 )
      • What Is Store Procedure
      • Create First Application in MVC
      • How To Install Visual Stdio Step by Step Process
      • Overview of CSS
      • Overview of HTML
      • What is LINQ
      • Overview
      • Difference Between function v/s store procedure
      • What is Function in Sql Server
      • How To Create DataBase & Table in SQL Server
      • SQL Select
      • Open Application in MVC
      • MVC OverView
    • ►  February ( 3 )
Powered by Blogger.

Categories

  • AdvanceQuery
  • CreateApplication
  • CreateDb
  • CssOverview
  • Evolution
  • Formatting
  • Function
  • FunctionVSSp
  • HtmlOverview
  • InstallVisualStudio
  • Introduction
  • javascriptOverview
  • JsValidation
  • Mvc-vs-Asp.Net
  • OverView
  • Select
  • SqlCommand
  • SQLOverview
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © MVC | Powered by Blogger
Design by Vibha Acharya