How to use other cols in group by which does not need grouping.

HI,
saleshistory table has sales record of each empoly, day wise.
that is saleshistory has more than one record of empid in it.
empcode is number(9,0) and empname is varchar2(200), sales number(10,5),empid is number(10,0)
select empid, sum(sales), max(empname), max(empcode) from saleshistory
group by empid ;
or
select empid, sum(sales), empname,empcode from saleshistory
group by empid ,empname,empcode ;
i want to find the total amout of sales done by each employee with empid,empname,empcode in select list.
1) please tel me which method good which i should follow or is there any other good way to get it.
yours sincerely
Edited by: 944768 on Apr 20, 2013 5:14 AM
Edited by: 944768 on Apr 20, 2013 5:15 AM
Edited by: 944768 on Apr 20, 2013 5:15 AM
Edited by: 944768 on Apr 20, 2013 5:16 AM
Edited by: 944768 on Apr 20, 2013 5:34 AM
Edited by: 944768 on Apr 20, 2013 7:08 AM

Hi,
This sounds like a job for the analytic SUM function.
Since you didn't post CREATE TABLE and INSERT statements for your own table, I can't test with your table. I'll show how to do his using the scott.emp table instead. In scott.emp, there can any number of rows with the same job, just as in your table there can be any number of rows for the same empid.
SELECT       job
,       sal
,       SUM (sal) OVER  (PARTITION BY  job)     AS total_sal
FROM       scott.emp
ORDER BY  job
;Output:
JOB              SAL  TOTAL_SAL
ANALYST         3000       6000
ANALYST         3000       6000
CLERK           1300       4150
CLERK            950       4150
CLERK            800       4150
CLERK           1100       4150
MANAGER         2850       8275
MANAGER         2975       8275
MANAGER         2450       8275
PRESIDENT       5000       5000
SALESMAN        1500       5600
SALESMAN        1250       5600
SALESMAN        1250       5600
SALESMAN        1600       5600Most aggregate functions (like SUM) have analytic counterparts which can get the same results without collapsing the result set down to one row per group. The PARTITION BY clause of analytic functions corresponds to the GROUP BY clause used with aggregate functions.
944768 wrote:
... when we used GTT in Stored proc (SP) is it necessary to truncate it at the begining of sp , if one truncate can it create any harm, as SP is used by many people at the same time.This seems to be a completely separate question. Most of your message involved grouping and the SUM function; it has nothing to do with Global Temporary Tables or stored procedures. You might have an application that uses a stored procedure and a global temporary table, and which also uses groupng and the SUM function, but that doesn't mean you hve a problem that involves all of them. If the stored procedure problem has anything to do with the grouping problem, explain it. If it is a completely separate problem, then start aompletely separate thread or it (and explain it).
I hope this answers your question.
If not, point out where the query above is producing the wrong reslts, and explain, using specific examples, how you get the correct results in those places.
If you want to use your own table, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002}

Similar Messages

  • How to invoke a jsp page from java which does not use Servlets?

    Hello,
    I am working in Documentum. I am trying to invoke a jsp page from another java page which does not use Servlets.
    I tried doing this by just instantiating the java class related to the jsp page from my present java class.In my java class related to the jsp page, I have defined onInit() and onRender() methods.
    Now, I am trying to call the jsp page from my present java class by just instantiating the java class related to the jsp page. This throws a java.lang.NullPointerException.
    Any comments or suggestions on this.Any help would be appreciated.
    Thanks,
    Ranjith M.V

    RanjithM.V wrote:
    Hello,
    Thanks for the reply. One important thing I forgot to mention. I am also using xml component.And?
    As this is the standard way used for coding in Documentum, I do not want to use Beans.Well, JSP's should, in and of themselves, contain no functional code. It should all be only display.
    Without that is it not possible?What did I say? I said,
    masijade wrote:
    It is possible, but I very, very, very, much doubt, that it would be worth the effort.And, if you don't know how, a forum is not truely going to be able to help you implement it (at least not in less than a few years time, at which point it would be outdated).
    >
    Appreciate your understanding and help.
    Thanks,
    Ranjith M.V

  • How to install Adobe Reader on a PC which does not have Internet Access?

    Hi
    I have a neighbour who does not have Internet access. He wants to be able to open PDF files. He is using 64 bit Windows 7.  Is there a link to an EXZE file that I can download?
    Thanks
    Geoff

    Hi Geoff
    Have a look at ftp://ftp.adobe.com/pub/adobe/reader/win/
    Regards

  • How to use BAPI extension for updating field which is not in BAPI stracture

    I am doing a conversion for control cycle create. The data is maintained in DB Table "PKHD". i have to update 12 fields threre through BAPI "BAPI_KANBANCC_CREATE". there are 11 fields in BAPI structure. but 1 field called"BERKZ" is not there . How can i update it through EXTENSION.

    Hi ,
    in the bapi extension check one structure with name BAPIPAREX will available..
    you need to pass custom structure in that..
    ands conactenate 12 field of your structure and pass in to value1 in bapirex structure and append.
    go to se11 and enter >bapiparex> check where it is used -->see the zprogram and check how it is used the add your code according to that..
    Regards,
    Prabhudas

  • How can I download CS5 to a computer which does not contain an optical drive?

    I am considering purchasing a 8GB Ultrabook (Sony or Dell) and was wanting to install Adobe CS5 onto it. I purchased Adobe CS5 suite last year via disc and have only realised Ultrabooks do not have a DVD drive. Is there a way I can install my purchased copy via an Internet download using my registration/security key or do I need to purchase an external DVD RW drive to install the software?
    Will a 8GB Ultrabook be sufficient to run Adobe CS5 on?

    Deeselle you can download CS5 from http://prodesigntools.com/all-adobe-cs5-direct-download-links.html.  Please make sure to complete the Very Important Instructions section prior to scrolling down the page and clicking on the download links.

  • I bought a used iPhone and found him email iCloud does not affect me so how can I deleted this email in order to use the device freely and privacy

    I bought a used iPhone and found him email iCloud does not affect me so how can I deleted this email in order to use the device freely and privacy
    help me please

    You can't. Return the phone for a refund, if you can, because without the previous owner's Apple ID/Password, you will not be able to re-activate the phone. It will be useless to you.
    Apple can't/won't help you with this.

  • How to use "url.openStream()" . What this function does?

    how to use "url.openStream()" . What this function does?
    Edited by: sahil1287 on Apr 16, 2009 10:02 PM

    http://java.sun.com/javase/6/docs/api/java/net/URL.html#openStream()
    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

  • How to use time capsule for wireless back-up but not internet?

    Hello,
    I have a tower and recently a laptop at work. The tower is connected to our local network with an ethernet cable and the laptop with wireless. So, the internet connection is fine for both.
    I was hoping to use my time capsule to do time machine backups on my laptop. Do you have any advice on how to configure this? I do not want to use the time capsule to extend my Internet, as I believe my work I.T. would prefer to handle all access to their  network.
    Perhaps there is some documentation about doing this that you could point me to? I have not been able to find it.
    Thank you for your help.

    Your original question was How to use Time Capsule for wireless back-up but not Internet?
    There is no reason for you to connect the tower....or anything else...using Ethernet if your goal remains that same as you stated.
    If you are asking if you can backup the Tower using Ethernet, and not wireless, then you can connect the tower to one of the LAN <-> ports on the Time Capsule....not the WAN port.
    Yes, it appears to work without plugging into my tower.
    Correct, it will work.
    I just have to select the network that it created. Of course, I have no access to the Internet while this is happening and it can not auto backup, unless I am on that wireless signal.
    As I stated, that is the downside to trying to back up without an Internet connection.  You have to establish another network...and backup over that network.
    If you are asking if you can stay connected to the work network while also backing up to your non-Internet "private" network, that is not possible.

  • I have a song that skips on my main mac because its a downloaded copy. But on my other devices(iPad, Apple TV) it does not skip because its in the cloud. How do I make a downloaded song back into the cloud?

    I have a song that skips on my main mac because its a downloaded copy. But on my other devices(iPad, Apple TV) it does not skip because its in the cloud. How do I put a downloaded song back into the cloud?

    Delete the track from the iTunes library, but not from the cloud.

  • CIF Error: Setup group/key 10000427 does not exist

    Dear CIF-Specialists,
    We observed a problem on the integration between APO and R/3.
    If we want to send PPM's from R/3 to APO we have the following error-message: "Setup group/key 10000427 does not exist".
    Transaction CFM1 (Create Integration Modell) ==> No problem
    Transaction CFM2 (Activate Integration Modell) ==> Error!
    We don't use setup groups or keys in our operations but we have created the setup keys in APO and R/3 (Transaction: /SAPAPO/CDPSC6 and OP43).
    As we don't have keys in the PPM's it is normal that they don't exists.
    Do you have an idea where we have to set theses Setup keys?
    Can you give us an indication how we could resolve this problem?
    Thank you.
    Best regards,
    Thomas

    Dear Sharath,
    Thank you for your reply.
    We dont't have setup key or group maintained in this receipt. This is the strange part on this problem.
    Why does it search for a setup key if we don't want to transfer it?
    I checked also the setup-keys in APO and R/3 and they are the same.
    We did a copy of the test-system (where the problem occurs) some days ago. Is there a table in APO where it could have some old entries about this?
    Thank you for your help.
    Thomas
    Edited by: Ricci Olivier on May 12, 2008 11:39 AM

  • I've moved my Aperture library to another computer, and masters are referencing an old path name.  How can I update these references?  Reloctating masters does not work in this case :(

    I've moved my Aperture library from one computer to another using Finder.
    I merged the library with one which was already on the computer.
    Now, the photos I imported have reference to the old path name on my old computer.
    How can I update these references as "Relocate Masters" does not work in this case?

    Just one suggestion to be able to reconnect all at once:
    Create a smart album containing the images with missing masters:
    File -> New ->  Smart Album,     and add a rule: File Status is "Missing"     (or File Status is "offline")
    Then select the images in this album and go to the File menu:
    and select:   File -> Locate referenced File
    If you are lucky, Aperture will reconnect all at once, if you point the first image version to its counterpart.

  • How do i remove my old Apple Id from iPhone's iCloud setting which does not exist anymore

    Purchased new iphone 5s, installed with itunes restoring backup from iphone 4 (which was too old a backup). It restored an old apple id (which i do not use anymore) in the iCloud settings while having my new Apple Id in the Itunes & App Store. I cannot turn off the iCloud setting due to old AppleId popping up - which does not exist.. How do i remove the old Apple Id from icloud setting on the phone.
    I cannot erase the phone as it asks for the password for the old Apple Id. And i cannot do the restore again (after i made a recent back up my iphone 4) as itunes asks me to turn off Find my phone.

    The Apple ID exists. The email address you used to create it may not, but the Apple ID does. Call AppleCare and ask to speak to someone in account security.

  • I have an iPad 2 and so does my mom.  We both have the app Slotomania and now all of sudden after having it for months, our games connected and we don't know how to fix it.  Deleting it and reinstalling does not work.

    I have an iPad 2 and so does my mom.  We both have the app Slotomania and now all of sudden after having it for months, our games connected and we don't know how to fix it.  Deleting it and reinstalling does not work.

    Does the app now use iCloud, do you use iCloud and do the two of you use the same account on iCloud?
    Just a guess.

  • How to create an OAF page that does not need login to access

    We have a lot of Oracle users, and everyday there are some users forget there username or password and need reset. I really want to use a web page to let them reset their passwords automatically. The web page will call the API to reset password if it found the user request is legible.
    So based on the situation, the users should not need a login to get to this page, can I do this using OAF?
    And idea is welcome, thank you for your help!
    -Bill
    Edited by: billzheng2004 on Jun 18, 2009 12:12 PM

    Srini,
    Thank you for your response, I think we need to go back to my original question, is it possible to create an OAF page that does not need login, how can I do that.
    I think I said too much and led us to go to a different direction I did't want to. But I am still glad to texplain why I need a custom password reset process, that is all about business requirement, here it is:
    ----I am not sure that "company issues" (such as what you described) can be solved by software -
    I already have a solution for that. Create a custom OAF page, ask user to input his SSN / Date of Birth.... then I can figure out what his real username easily. And I can reset his password as his SSN or something which only this particular user knows. Then he can login.
    ----you may have to impart training to end users.
    As I mentioned, most of our users use only Benefit self service. They only login several times a year, even they are trained this year, most of them will forget next year, this is just human nature. And because the nature of our business, thousands of employees may change at the end of a year. It does not make any business sense for company to prepare trainers every year.
    ----In any case, the functionality you require is already built into the product.
    I guess the reason most companies hire Oracle Developers is that some functionality Oracle Applications provide is not exactly the companies needed. When there is Oracle Apps product, there is alway customization.

  • How can I add location to a photo that does not have a gps location? On iPhoto it was easy.

    how can I add location to a photo that does not have a gps location? On iPhoto it was easy.

    You can use the Settings in the slideshow to Show Captions,  either the Description filed be display, the Title field or both.
    If you create the slideshow in iDVD from still photos from iPhoto you can add the Description and/or Title via the settings in iDVD.
    Since iDVD adds both automatically the user must go thru the slideshow and remove those items not wanted.

Maybe you are looking for

  • How do I get rid of duplicate songs on my iPad that cannot be deleted?

    I bought an album very recently off iTunes (Lana Del Rey - Paradise Edition), and when I sync the album along with all my other songs from my mac to my iPad, the album has every song duplicated, with the second song of every copy unable to be played

  • Alert: Photo cannot be Opened?

    I am using iPhoto 08 with a Canon Powershot S5 (8MP) and when I try to transfer my photos from the camera to iPhoto, I get a message saying: Alert: The Photo *Insert file name* could not be opened, because the original item cannot be found. But after

  • HT1212 how can i sync my iphone to itunes as it is disabled and i cant do anything at all ?

    the phone is disabled and it wont let me do anything at all to it, and i need to sync it to itunes, but the problem is it hasnt been sync to a persific itunes.

  • Charged twice, bill inconsistent.

    So ever since my wife and I changed plans our bill has fluxuated widlly over the last three months. The first bill was $230 which is higher than it should be but it was also the first bill of the new plan, which I know can be higher. THe second bill

  • Problem in resizing multicolumn listbox in

    I am using multicolumn listbox to show my test to user. In development PC it looks nice and displays as much as column I want but in other PC where I am installing my application there last row column is partially visible. I have set VI to resize the