What kind of input parameter is used in SUM function?

Hi Everyone,
As we know sum is a predefined oracle function. But what these oracle guys have used for the input parameters. How they have done this?
I mean we can write this sum fuction like so many ways like as mentioned below. Please give me some ideas how to do that.
SELECT SUM(salary) as "Total Salary" FROM employees;
SELECT SUM(DISTINCT salary) as "Total Salary" FROM employees;
SELECT SUM(income - expenses) as "Net Income" FROM gl_transactions;
SELECT SUM(sales * 0.10) as "Commission" FROM order_details;Regards,
BS2012

BS2012 wrote:
Hi Everyone,
As we know sum is a predefined oracle function. But what these oracle guys have used for the input parameters. How they have done this?
I mean we can write this sum fuction like so many ways like as mentioned below. Please give me some ideas how to do that.
SELECT SUM(salary) as "Total Salary" FROM employees;
SELECT SUM(DISTINCT salary) as "Total Salary" FROM employees;
SELECT SUM(income - expenses) as "Net Income" FROM gl_transactions;
SELECT SUM(sales * 0.10) as "Commission" FROM order_details;Regards,
BS2012As others have said, your question is not quite clear.
There are many aspects and angles to looking at what you are asking.
Primarily, from a top-level, the sum function simply takes a number value as it's argument, so all those examples you have given have expressions in them that evaluate to a numeric value before being supplied to the sum function. (As someone else already mentioned you can have non-numeric datatypes, just so long as they can implicitly be converted to a numeric value).
From a statement parsing and execution perspective, the contents of the expression inside the brackets will be evaluated before being passed to the sum function. It is not the sum function that itself takes the expression and evaluates it. The sum function just expects a single numeric value.
Internally, what the sum function does, is more than just a single... call function and return value, because it has to deal with multiple values being passed in as part of the aggregating group. As such, it needs to have the ability to know when to start it's summing, to accept multiple values as input so it can sum them together, and to know when to stop summing inputs and pass the result back.
If we write our own user defined aggregate function (other people have already provided a link to explain such) we can see what is happening internally. In this following example, we'll write a user defined function that multiplies the values rather than sums them...
create or replace type mul_type as object(
  val number,
  static function ODCIAggregateInitialize(sctx in out mul_type) return number,
  member function ODCIAggregateIterate(self in out mul_type, value in number) return number,
  member function ODCIAggregateTerminate(self in mul_type, returnvalue out number, flags in number) return number,
  member function ODCIAggregateMerge(self in out mul_type, ctx2 in mul_type) return number
create or replace type body mul_type is
  static function ODCIAggregateInitialize(sctx in out mul_type) return number is
  begin
    sctx := mul_type(null);
    return ODCIConst.Success;
  end;
  member function ODCIAggregateIterate(self in out mul_type, value in number) return number is
  begin
    self.val := nvl(self.val,1) * value;
    return ODCIConst.Success;
  end;
  member function ODCIAggregateTerminate(self in mul_type, returnvalue out number, flags in number) return number is
  begin
    returnValue := self.val;
    return ODCIConst.Success;
  end;
  member function ODCIAggregateMerge(self in out mul_type, ctx2 in mul_type) return number is
  begin
    self.val := self.val * ctx2.val;
    return ODCIConst.Success;
  end;
end;
create or replace function mul(input number) return number deterministic parallel_enable aggregate using mul_type;
/So, our user defined aggregate function is based on an aggregate object type.
This object holds a value ("val" in our example).
It has an Initialize method, so when the SQL engine indicates that it's the start of an aggregation of values it can set it's value to an initial value (in this case null).
It has an Iterate method, so as the SQL engine passes values to it as part of the aggregated set of values, it can process them (in our case it multiplies the input value with the value it already has for this set of aggregations (and takes a base value of 1 for the first iteration))
It has a Terminate method, so when the SQL engine indicates that the aggregate set of values is complete, it can return the result.
The last method in there is a Merge and is a mandatory requirement, so that when aggregation is done using parallel evaluation (to improve performance internally), the results of those parallelly executed aggregations can be combined together (see http://docs.oracle.com/cd/E11882_01/appdev.112/e10765/ext_agg_ref.htm#ADDCI5132). As we're multiplying numbers, in our case, it is simply a case of multiplying one result with the other.
And to see it working...
SQL> with t as (select 2 as x from dual union all
  2             select 3 from dual union all
  3             select 4 from dual union all
  4             select 5 from dual)
  5  --
  6  select mul(x)
  7  from t;
    MUL(X)
       120

Similar Messages

  • What kind of input for Wrapping tool

    Hi
    I am using below command for wrapping tool
    IntuneMAMPackager -i /Users/xyz/Desktop/upload/myapp.ipa -o /Users/xyz/Desktop/upload/output/myapp_Wrapped.ipa -p /Users/xyz/Desktop/upload/xyz_Distribution.mobileprovision -c 7878200C2E4B2F892BB53E75F4042461474CD112
    What kind of input supposed to give for "-i" parameter?
    As my understanding we can give input as ".app or .ipa" for the Wrapping tool, Is that correct?
    Can we give input as "apps downloaded from apps store"?
    Can we give input as "installed apps on the mac machine(eg: App Strore.app)
    Can we give  input as ".ipa(myapp.ipa) which is created for my app using xcode from developement profile and certificate"?
    Can we give input as ".ipa(distrubitioon/enterprise ipa) which is created using xcode from distribution profile and certificate"?
    Waiting for your reply,
    Regards,
    Venkatesh Guttal

    The Mini comes with an HDMI->DVI-D adapter.  So, if your monitor
    supports DVI-D you are set.  If it supports HDMI, you just need an
    HDMI cable.
    If it only supports VGA, you will need a Display Port->VGA adapter.

  • What kind of database the SSMA uses to store metadata in the file named "source-metabase.mb" ?

    What kind of database the SSMA uses to store metadata in the file named "source-metabase.mb" ?
    I'm looking for the method to open the file and add 'cutom migration script' (some automatization).

    Hi Poman.Pokrovskij,
    When you generate SSMA Assessment Report, there are several files created and saved into Report folder under your SSMA project folder. It includes
    source-metabase.mb, project-container.mappings, preferences.prefs, and so on.
    . MD files are usually saved in plain text format including inline text symbols, defining how a text is formatted such as the indentations, its table formatting, fonts, and headers.
    SSMA provides a project setting that allow you to customize how to set customized database migration. For example, to customize data migration SQL statement, you can modify project setting by navigating to Tools and choosing Project Settings,
    then looking for the setting for
    Extended Data Migration Options and change the value to
    Show. You can select use custom select and modify the SQL statement.
    For more information about SSMA for Oracle, you can review the following articles.How To Perform Incremental Data Migration Using SSMA:
    http://blogs.msdn.com/b/ssma/archive/2010/10/04/how-to-perform-incremental-data-migration-using-ssma.aspx
    Using SSMA Project Setting to Customize Database Migration:
    http://blogs.msdn.com/b/ssma/archive/2011/03/16/using-ssma-project-setting-to-customize-database-migration.aspx?Redirected=true
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • I have a videocamera minidv what kind of cable i had used to import the movie?, I have a videocamera minidv what kind of cable i had used to import the movie?

    I have a videocamera minidv what kind of cable i had used to import the movie?

    Which MiniDV Video Camera?
    What version iMovie do you have on your Mac?
    For starters, have a look at > Apple - Support - iMovie

  • How can I find out what kind of battery my computer uses in order to buy a replacement?

    I purchased a new Macbook Pro 13" in January 2012. Unfortunately, I did not purchase Apple Care. My trackpad seems to have taken on a life of it's own. I'm guessing this is due to a swollen battery. How can I find out what kind of battery my computer uses in order to buy a replacement?

    Take a look at this link, http://store.apple.com/us/search/macbook-pro-battery-replacement?mco=Nzc1MjMwNg
    This is the MacBook Pro repair answers, http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=Macn otebooks

  • What kind of mouse do you use?

    The trusty Logitech wireless mouse that I've used for about 5 years now is nearing the end of its life and I'm looking for suggestions on a replacement. The Arc Mouse by Microsoft has received some nice reviews; so far it's at the top of my list.
    Simple question, what kind of mouse do you use now?

    I'd vote Logitech's Performance MX mouse all the way! (assuming that you are right handed though, it is really made for right-hand use only)
    Love them!
    It is a cordless, rechargeable design with a laser that works on just about any surface, even glass. The scroll wheel is butter smooth and has inertia for massive scrolls.
    This is one of the most expensive options out there, but IMHO so worth it.
    Regards,
    Jim

  • I want to create a 5" x 7" multiple page booklet in Pages  what kind of template do I use to make sure the information is on the right page and will print on the proper sheets?

    I want to create a 5" x 7" multiple page booklet in Pages.  What kind of template do I use so the text prints in order on the pages and on the right sheets?  HELP!!!!

    While there are templates available for several n page booklets, using them requires a separate template for each size (in pages) booklet you'll want to make.
    A better method is to use some form of imposition software for mac that will do the imposing (placing each page on the correct sheet) using a copy of your content, printed to a PDF document. The link is to a Google search using that phrase as the search term.
    For a more detailed discussion of imposition and some of the available software, see Peter Breis's post "imposing booklets" at the iWork Tips & Tricks site. (Scroll down)
    Regards,
    Barry

  • What kind of transport request is used to transport custom table contents ?

    What kind of transport request is used to transport custom table contents ?
    Also what kind of transport request is used to transport SAP standard table contents ?

    Create Workbench request only.
    Because when u will transport the table from development server to quality that time table records won't transport.
    We don't have any TR type to transport table with records.
    If usefull reward points helpfull.....
    Regards,
    Rajneesh Gupta

  • What kind of cloth do I use to clean my iPod nano?

    I just got my white nano this morning, and I've been reading all these terrible stories about people cleaning their nano with a cloth only to scratch it up terribly. So, what kind of cloth should I use then? And where would I get it? I heard people talk about displex (sp?) to remove scratches. Does anyone have first hand knowledge that it really works?
    Thanks!

    AFter I wiped kleenex tissue to clean the fingerprints off my nano, I looked and saw many little scrathes that werent there before. THe sratches were only visible when you looked at the nano at a certain angle and under a certain amount of light. I suppose the scrathes were made because of the little particles in the kleenex tissue. Unfortunatly, the little particles were also left behind on the nano after wiping it so it got annoying having to wipe the particles off.

  • What kind of camera can I use??????

    I need to measure crack length in fatigue test of an Aluminium sample automatically. For example, the camera can take shots (Images) every 4000 cycles (fatigue load cycles), maybe more cycles.
    For my test, I need to measure both sides crack length (right side and left side of specimen centre line), shown in Fig1.  So I need to take shots both crack tips at the same time, which means camera must have a large field view and the resolution should measure 0.01mm, to see both crack tips clearly. At the end, I must be able to acquire images from Labview. I can save all the images into my fold from Labview, then I can measure crack lengths in left and right side from every image.  Fig1. sample size and crack tip
    Would you please give me any suggestions on the characteristic/specifications of this kind of camera?
     What kind of camera can I use? How much this kind of camera? Where can I order this kind of camera?
    Attachments:
    camera-Fig13.jpg ‏16 KB

    Hi Cran.
    You might want to put this topic into the Hardware Forum instead.
    It seems that this isn't much of a LabView question......
    Regards BCL
    Don't forget to rate a good Answer....
    Here should be some cool signature
    But there's NOT
    LV7Express, LV8.5.1

  • What kind of cable can I use?

    Hello,
    I recently bought an iMac and I was wondering what kind of cable can I use to connect it to my Macbook Air so that I'll be able to transfer my files faster.
    Any links to a website that has a picture or actually sells the appropriate cable would be greatly appreciated as I currently live Paris and communicating with store clerks is a mission in and of itself!
    Thanks a lot.

    get the usb-ethernet adapter for the MBA and then an ethernet cable to attach the two computers. OR: create a computer to computer wireless airport connection so that the computers can access the N wireless network both are capable of but some routers are not. If the MBA is the more recent revision, you may have gotten the usb-ethernet adapter included in the package; otherwise, it can be purchased from the Apple Store. The ethernet cables are standard and can be obtained from any computer store. No need for anything special like crossover cables, macs connect directly with a standard cable.
    I tried to transfer files quickly via a simple 802.11g wireless LAN I had set up via a router but it was so slow that I set up the c to c network via the menubar airport menu and was able to quickly copy and transfer files via the 802.11n that the airport hardware provides when something else does not interfere with the speed that the macs are capable of wirelessly.
    Message was edited by: Rhyd
    Message was edited by: Rhyd

  • What kind of convertor can I use with my I mac in Israel?

    What kind of convertor can I use with my I Mac in Israel?

    What do you want to convert? More details about what you are trying to do would help.

  • What kind of printer would you use to print on a lorry?

    Hi,
    One of my client sells items from the lorry, so he wants his drivers to print invoices on the way. My question is what kind of printer would you use to print on a lorry? Any idea, experience?
    Thx in advance,
    Laci

    Hi Laci,
    There are quite a few mobile printers, for example HP does a range of battery powered Officejet printers which you could use on the go. For instance, check this out:
    http://www.shopping.hp.com/product/CB026A%2523B1H
    I hope this helps!
    xx Nat

  • What kind of adhesive does Apple use?

    The bottom case of my TiBook is a little loose at the battery corner. When I type and rest my palms on the top case, it kind of "pops" or "clicks" a bit as the pressure moves the top and bottom cases together. It's not a big deal, but it's annoying enough to want to fix. I tried to get the folks at my local Apple repair center to deal with it under Applecare (I have about a month left.) They said it wasn't a warrantied problem, but they did offer to glue it for free. I didn't think that was a good idea, so I declined. I have since been told that Apple glued the bottom cases of the TiBook to the frame at the factory, so that would have been the appropriate repair.
    If that's true, what kind of adhesive did Apple use for that, and exactly where was the glue applied? It must have been a prettty strong glue, and sparsely applied, as I didn't see any traces of it when I took the bottom off the computer. In any event, if gluing is the right move, I'd just as soon do it myself. The repair center would take at least a week, since they're usually so backed up. But I don't want to use anything that might damage the case or leak into anything.
    Thanks in advance for your help.

    The metal skin is really glued around the edge by a plastic frame. It is this frame that holds the skin to the main frame and can give problems.
    I had to open my ti case to install an airport card. I either did it wrong or the apple glue job was poor because the gray plastic trim around the edge of the metal skin had come loose over 50% of the circumference.
    I had a commercial 3M rubber cement on hand so I used that. I applied it with a toothpick very sparingly (of course the rubber cement gets stringy so the job was a ittle messy).
    I let dry in a warm room for 24 hours. The reason I did that was fumes from curing glue can be caustic and attack some very thin metals etc. I fugured I wanted to lose any fumes before I trapped them in the warm computer.
    It worked well and I haven't had a repeat of the problem.

  • HT5299 What kind of cable should I use for movies on my macbook pro if I want to watch it on my 60 inch tv?

    What kind of cable for my macbook pro, do I use to watch movies on my 60 inch tv ?

    Which model MacBook Pro do you have (e.g., "15-inch Late 2011")?
    Clinton

Maybe you are looking for

  • If condition in a Package

    Hi all, I am new to ODI. I have got the following requirement. I have got two interfaces. 1. Daily Sales 2. Monthly Sales. My requirement is to execute the Daily Sales interface every day except the First Day of the Month. On the First Day of the mon

  • RS482M4 no s-video output after clean install

    I recently installed a new HDD and performed a clean install of XP MCE on my HTPC.  I have an MSI RS482M4 #MS-7191-020 mobo with AMD Athlon 64 SB 80GB HDD and XP MCE.  I am trying to output to my LG 37" LCD via the s-video and am not able to do so.  

  • Unable to set DFF context value

    Hi, i want to set DFF context value with a variable, so i tried first to set it with a constant. in the controller's PR super.processRequest(oapagecontext, oawebbean); // first, find the flexfield's handle OADescriptiveFlexBean oaDFF; oaDFF = (OADesc

  • How to run Backup in Server 2012

    Hi am Using windows Server 2012, am able to take backup only from Local drives. i want to Run even mapped network drives also.. please guide me how to take backup of network drives or mapped network drives.

  • Delete P-P CS6 after CC installation?

    New to the Premiere-Pro and video side of things ... Lightroom's last few iterations have installed themselves and 'de-installed' my previous programs, nicely saving computer space (though I know some don't like that behavior). I just up-dated to CC