Oracle AVG () absolute average

Source: Internet
Author: User
Tags select from where

Original Sticker Address

Problem:

Table: Visits

Numb   visitnumb
----------------
sd01       12628
sd02     6168216
sd03  
sd04     2308646
sd05    29979109
sd06  
sd07      699879
sd08     1512191
sd09     5771408
SD10      2393528
sd11      832988
sd12  
SD13   
sd14  
gd06      492559
gd04       928430
gd02     1881556
gd01     5759619
gd07      955794
gd09     4207098

NUMB Visitnumb
------ ----------
GD10
GD03
GD05
GD08

Problem: Ask for rows that are larger than all visitnumb averages

If you simply use:

  Select from where Visitnumb > from visits);

This is not possible because AVG automatically filters out the value of the empty Visitnumb value.

That's right:

Selectfrom where Visitnumb>(selectavg (nvl (visitnumb, 0 )) (fromvisits);

If Visitnumb is empty, it is assigned a value of 0, so the absolute mean is calculated (including the empty row).

Oracle AVG () absolute average

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.