Page Rank

Subscribe

Categories

Recent posts

Alexa Rank

Different SQL functions


 

  • SQL has many built-in functions for performing calculations on data.

SQL Aggregate functions

  • SQL aggregate functions return a single value, calculated from values in a column.

Useful aggregate functions:

    AVG() – Returns the average value

    COUNT() – Returns the number of rows

    FIRST() – Returns the first value

    LAST() – Returns the last value

    MAX() – Returns the largest value

    MIN() – Returns the smallest value

    SUM() – Returns the sum

SQL Scalar functions

  • SQL scalar functions return a single value, based on the input value.

Useful scalar functions:

    UCASE() – Converts a field to upper case

    LCASE() – Converts a field to lower case

    MID() – Extract characters from a text field

    LEN() – Returns the length of a text field

    ROUND() – Rounds a numeric field to the number of decimals specified

    NOW() – Returns the current system date and time

    FORMAT() – Formats how a field is to be displayed

The AVG() Function

  • The AVG() function returns the average value of a numeric column.
  • SQL AVG() Syntax

SQL COUNT() function

  • The COUNT() function returns the number of rows that matches a specified criteria.
  • SQL COUNT(column_name) Syntax

SQL COUNT(*) Syntax

  • It returns total no of data in a table.

SQL COUNT(DISTINCT column_name) Syntax

  • It returns count distinct column.

The FIRST() function

  • The FIRST() function returns the first value of the selected column.
  • SQL FIRST() Syntax

The LAST() function

  • The LAST() function returns the last value of the selected column.
  • SQL LAST() Syntax

The MAX() function


  • The MAX() function returns the largest value of the selected column.
  • SQL MAX() Syntax

The MIN() function

  • The MIN() function returns the minimum value of a selected column.
  • SQL MIN() Syntax

The SUM() function

  • The SUM() function return the sum of values in the selected column.
  • SQL SUM() Syntax

The GROUP BY Statement

  • The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.
  • SQL GROUP BY Syntax

The Having Clause

  • The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions
  • SQL HAVING Syntax

The UCASE() function

  • The UCASE() function converts the value of a field to uppercase.
  • SQL UCASE() Syntax

The LCASE() function

  • The LCASE() function converts the value of a field to lowercase.
  • SQL LCASE() Syntax

The MID() function

  • The MID() function is used to extract characters from a text field.
  • SQL MID() Syntax

The LEN() function

  • The LEN() function returns the length of the value in a text field.
  • SQL LEN() Syntax

The ROUND() function

  • The ROUND() function is used to round a numeric field to the number of decimals specified.
  • SQL ROUND() Syntax

The NOW() function

  • The NOW() function returns the current system date and time.
  • SQL NOW() Syntax

The FORMAT() function

  • The FORMAT() function is used to format how a field is to be displayed.
  • SQL FORMAT() Syntax

 Different SQL functions


VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">