Can we add(sum) the rows while quering the whole table in one statement.

Hi,
I have a table "create table test1(id number(5), name varchar2(10), salary number(10,2))" with the data
ID     NAME     SALARY
1     AAAAAA     55000
2     BBBBB     15430
3     CCCCC     15430
4     DDDDD     25430
5     EEEE     29830
6     FFFFF     7645
7     GGGGG     6546
8     HHHHH     9645
9     IIIIII     7584
I need a select query which gives the result like this ie.., the 10th row should be the sum of all the 9 rows...
ID     NAME     SALARY
1     AAAAAA     55000
2     BBBBB     15430
3     CCCCC     15430
4     DDDDD     25430
5     EEEE     29830
6     FFFFF     7645
7     GGGGG     6546
8     HHHHH     9645
9     IIIIII     7584
10 Total 172540

Or;
create table t as (
  select 1 id, 'AAAAAA' name, 55000 salary from dual union all
  select 2, 'BBBBB', 15430 from dual union all
  select 3, 'CCCCC', 15430 from dual union all
  select 4, 'DDDDD', 25430 from dual union all
  select 5, 'EEEE', 29830 from dual union all
  select 6, 'FFFFF', 7645 from dual union all
  select 7, 'GGGGG', 6546 from dual union all
  select 8, 'HHHHH', 9645 from dual union all
  select 9, 'IIIIII', 7584 from dual);
Table createdQuery;
with sub_tot as (
  select max(id) + 1 max_id,
    'Total' name,
    sum(salary) sum_sal
  from t)
select id, name, salary from t
union all
select max_id, name, sum_sal from sub_tot
order by id;
        ID NAME       SALARY
         1 AAAAAA      55000
         2 BBBBB       15430
         3 CCCCC       15430
         4 DDDDD       25430
         5 EEEE        29830
         6 FFFFF        7645
         7 GGGGG        6546
         8 HHHHH        9645
         9 IIIIII       7584
        10 Total      172540
10 rows selected

Similar Messages

  • How can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • How can I select and delete rows based on the value in one column?

    I searched through the discussion board, and found a thread on deleting blank rows, but not sure how to modify it to work with my issue.
    I have put together a rather complicated spreadsheet for designing control systems, it calculates parts needed based on check boxes selected in a second spreadsheet.
    Since not all systems require all parts there are many rows that have a 0 quantity value, I would like to select these rows and delete them once I have gone through the design phase (checking off required features on a separate sheet).
    I like the way the other thread I found will gather all the blank rows at the bottom without changing the order of the rows with data in them.
    I don't understand exactly how the formula in the other thread works well enough to modify it to look for a certain column.
    I hope I made myself clear enough here, to recap, I would like to sort the rows based on a zero value in one (quantity) column, move them (the zero quantity rows) to the bottom of the sheet, and then delete the rows with a zero quantity (I can delete them manually, but would like to automate the sorting part).
    Thanks for any help anyone can provide here.
    Danny

    I apologize but, as far as I know, Numbers wasn't designed by Ian Flemming.
    There is no "this column will be auto-destructing after two minutes"
    You will have to use your fingers to delete it.
    I wish to add a last comment :
    if your boss has the bad habit to look over your shoulder, it's time to find an other one.
    As I am really pig headed, it's what I did. I became my own boss so nobody looked over my shoulder.
    Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 20:30:25
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • HT201401 I can't add a contact or edit contacts the little + sign is no longer on my phone...same thing on my iCalendar.  I can no longer add events or dates.  how do I fix this?

    I can't add a contact or edit contacts the little + sign is no longer on my phone...same thing on my iCalendar.  I can no longer add events or dates.  how do I fix this?

    Reset your phone, hold the home and off button down until the apple symbol comes up. If that doesnt fix it then you need to restore your phone in itunes, Connect to itunes, right click on your phones name to the left, then click restore from backup. That providing you have backed up your phone recently.

  • Every time I repair my iPod with iTunes, it hangs at the end of the process (while checkin the recovery of iPod). What can I do?

    every time I repair my iPod with iTunes, it hangs at the end of the process (while checkin the recovery of iPod). What can I do?

    I chose to restore it to factory defaults, but that never succeeded.
    It hangs at the end of the process.
    printscreen:
    http://users.telenet.be/kevvanbelle/iPod/ipod.JPG
    Language is Dutch :-)
    Littery it says:
    Check of Recovery of iPod.
    Already for 40 minutes.
    I closed down iTunes.
    Now, when I turn on my iPod, there is the icon of iTunes with an usb cable towards it.
    When I attach it to my computer and turn on iTunes, the message is there that a iPod was stuck in recovery mode and I should retry it.
    And then I get the same story. Unpacking, installing, checking... blocked!

  • I have started a photo book in iPhoto (OS 10.7.5). How can I add photos that were not in the original album?

    I have started a photo book in iPhoto (OS 10.7.5). How can I add photos that were not in the original album?

    Thanks for your quick response. I thought I had tried that but I must not have because it worked perfectly.

  • Can i add watermarks to PDF files using the PDF Pack?

    Can i add watermarks to PDF files using the PDF Pack?

    Hi Susannah,
    Adobe PDF Pack does not allow you to edit a PDF file. For that, you would need Acrobat. You're welcome to try Acrobat for free for 30 days: see http://www.adobe.com/products/acrobat.html for more information.
    This Help document describes how to watermark a PDF in Acrobat: Add watermarks to PDFs
    Best,
    Sara

  • How to split the rows while data integration?

    Hi All
    Im a newbie to ODI. I just want to know whether it is possible to split the rows in the source datastore to populate the target datastore.
    Consider a table, say
    Target Table 1:
    a - varchar
    b - number
    sometimes i may get the source file like this
    source1:
    c1 c2
    a 1
    a 2
    b 1
    c 1
    c 2
    c 3
    or
    source 2:
    c1 c2 c3 c4
    a 1 2
    b 1
    c 1 2 3
    in case of source 1 , i can easily map the values directly to the target table. the problem is in the source 2 scenario. the number of values in one particular row is unknown. In this case is that possible to split the row and populate the target using ODI.
    Many thanks
    Message was edited by:
    user577332

    with interface i don't know but you can make an procedure which make this
    like
    Select c1,c2 from source2
    where c2 is not null
    union
    Select c1,c3 from source2
    where c3 is not null
    union
    Select c1,c4 from source2
    where c4 is not null
    this is an option if it doesn't work with Interfaces.

  • Can't add files or file aliases to the dock

    I can't add files or file aliases to the dock. All the help viewer says about this is this issue?
    "If you can't add icons to your Dock, your administrator may be preventing you from doing so."
    I am the administrator of this computer, as it turns out. What is the solution to

    Hi Wagnerian, Welcome to Apple Discusswions.
    When adding files or folders to the Dock, they must go to the right side of the hairline (the same side that Trash is on).
    If this what you are doing and it still doesn't work navigate to /Users/YourHome/Library/Preferences/com.apple.dock.plist and delete that file. then log out and back in or restart. (You'll have to reset your Dock the way you like it)
    -mj
    [email protected]

  • Can't add supervisor as Primary Supervisor in the "Team Configuration" menu.

    Dear All,
    I can't add supervisor as Primary Supervisor in the Team Configuration menu.
    What is wrong in my configuration?
    Thanks in advance
    Bahlul

    Hi Bahlul.
    I assumed that user has been imported on UCCX by selecting iccx extension on CUCM which automatically give agent capability to the user.
    If you use "user view" function on UCCX and then assign Supervisor capability to a user, you give him access to supervisor web page.
    To let the user to manage a team as supervisor, you have to define him also as an agent.
    That's the reason why you install both supervisor and agent desktop tool on Supervisor's Pc
    Anyway congrats for finding solution ;)
    Regards
    Carlo

  • How can I add a dip to white at the beginning of a clip?

    How can I add a dip to white at the beginning of a clip?  I know where to find it on Pr, but I'm new to AE.  I have 2 clips that need to transition one to the other.  The first clip ends by dipping to white; therefore, I need to either dip to white at the beginning of the 2nd clip & line them up so they overlap well, OR I need to find a white transition to place between them like in Pr.

    Make a whote solid.  Animate its opacity from 0 to 100 and back again.
    You'll use couple-three layers -- no automatic transitions in AE.  That's what Premiere's for.

  • How can i add an Engraving after i order the ipad ( add, not edit)

    how can i add an Engraving after i order the ipad ( add, not edit)

    Sorry, I don't mean to appear rude, but I don't understand the question. What do you mean "how do you call"? You pick up the telphone and call the store's number, just as you would any other person or company.
    None of the Apple Stores have on-line chat.
    Regards.

  • We can't add a decimal number column with the create table forms

    In the version 4, we can't add a decimal number column with the create table forms.

    In the GUI, I found the following column (I translate from french to english): PK, Name, Data_type, lenght, not null, default, comments.
    In the lenght field, if I enter 9,3 to have a NUMBER(9,3), I have a message saying that the number must be an integer.

  • How can I turn off the screen while keeping the mac awake?

    I am using teamviewer to remote connect to my office Imac from home. However, every time I connected, my imac screen will turn on and everyone else in the office can see what my imac is doing..
    Is there some method to turn off the screen while keeping the mac awake, so I can remote connect to it?
    PS: I am using OSX 10.7.3

    Energy Saver, you can keep the computer awake while the screen saver shuts the monitor off but I'm not sure that would do it for you.

  • Firefox won't let me use any of the links-I can't add new links by clicking on the + box. I can't delete or add links. I can't even open one of the links at the top of this page Thanks

    Firefox won't let me use any of the links-I can't add new links by clicking on the + box. I can't delete or add links. I can't even open one of the links at the top of this page

    I'm not sure what you mean by "the + box". Is that a feature on one of your toolbars?

Maybe you are looking for

  • Is there some way to put an arrow column 0 in a JTable?

    Hi, I'd like to configure my JTable something like "grids" in other languages like Delphi. There is a column 0 with a black arrow. When the user changes the line, the arrow is automattically updated to the actual line. Is there some property of JTabl

  • Problem with Facetime and my MacBookPro camera

    Hello, I've got a MacBookPro and I have a problem with Facetime and my front camera. When I have a discussion with an iMac or an other MacBook the image received by the other person becomes fix. To unfix it I have to put my finger on my camera and th

  • FMS on Amazon Web Services License. Does it need enter License(Serial Key)?

    FMS on Amazon Web Services License. Does it need enter License(Serial Key)? After Subscribe on adobe.com(Adobe Flash Media Server 4.5 on Amazon Web Services) I build the Amazon EC2 successfully. In amazonpayments, the amazon show me an Activation Key

  • Konqueror: Could not find service 'konqueror.desktop'.

    Suddenly konqueror stopped working. [rasat@localhost ~]# /opt/kde/bin/kfmclient openProfile filemanagement kfmclient: ERROR: Couldn't start konqueror from konqueror.desktop: Could not find service 'konqueror.desktop'. [rasat@localhost ~]#

  • How do i find my most recent movie rentals?

    how do i find my most recent movie rentals? I'm talking about the ones that were 30 days old and went away. I forgot one of the titles and i'm trying to find the list of what I rented