PL/SQL – aggregating, statistical functions

select count(*), -- 107, count all rows including nulls and duplicates
       count(distinct commission_pct), -- 7,counts only distinct values in column
       count(all commission_pct), --35, counts non nulls
       count(commission_pct) --equivalent to above 
from hr.employees;

select avg(distinct commission_pct), -- 0,25; average from distinct values
       avg(all commission_pct), --0,22; average on all values
       avg(commission_pct) --equivalent to above
from hr.employees;

select max(commission_pct), min(commission_pct), variance(commission_pct), stddev(commission_pct)
from hr.employees; -- selects max/ min/ variance/ standard deviation of selected column
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s