• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / function / COVAR_SAMP Function in Oracle SQL – PLSQL

COVAR_SAMP Function in Oracle SQL – PLSQL

November 27, 2012 by techhoneyadmin

The COVAR_SAMP Function in Oracle SQL / PLSQL is used to calculate the sample covariance of a set of numbers in pairs.

Syntax for the using the COVAR_SAMP Function in Oracle SQL / PLSQL is:

SELECT COVAR_SAMP(expression_1, expression_2)
FROM table_name;

  • expression_1 and expression_2 are numeric expressions
  • The COVAR_SAMP function in Oracle SQL / PLSQL will eliminate all the pairs where expression_1 and expression_2 are having NULL values.

Example:

Using COVAR_SAMP Function in Oracle SQL / PLSQL SELECT statement:

Suppose we have a table named ‘employee’ as shown below:

Employee_ID Employee_Name Salary Department Commission
101 Emp A 10000 Sales  
102 Emp B 20000 IT 20
103 Emp C 28000 IT 20
104 Emp D 30000 Support  
105 Emp E 32000 Sales 10
106 Emp F 40000 Sales 10
107 Emp G 12000 Sales 10
108 Emp H 12000 Support  

If we write our COVAR_SAMP Function query as:

SELECT COVAR_SAMP(salary, commission)
FROM employee;

We will get ‘-7500’ as output


Filed Under: function Tagged With: COVARSAMPPLSQL, COVAR_SAMP Function in oracle plsql, COVAR_SAMP Function in oracle sql, how to use COVAR_SAMP Function in oracle database query, how to use COVAR_SAMP Function in oracle plsql, how to use COVAR_SAMP Function in oracle sql, syntax and example of COVAR_SAMP Function in oracle database query, syntax and example of COVAR_SAMP Function in oracle plsql, syntax and example of COVAR_SAMP Function in oracle sql, using COVAR_SAMP Function in oracle database query, using COVAR_SAMP Function in oracle plsql, using COVAR_SAMP Function in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in