Average doesn't change with deletion of tuples?

Hi there, I am using Oracle 11g EE. I'd appreciate if you could shed some light on my confusion. The following statement attempts to delete all tuples in the ACCOUNT table when the balance falls below the average balance in the ACCOUNT table:
delete from account where balance < (select avg (balance) from account);
I was taught that there is an issue with this because as we delete tuples from the table, the average balance changes. I ran this statement and encountered no issues.
It correctly deleted the tuples where balance is less than the initial average of the table.
The solutions suggested to fix the potential issue are as follows:
1. First, compute avgbalance and find all tuples to delete
2. Next, delete all tuples found above (without recomputing avg or retesting the tuples)
My question is, does the average really get changed in the (select avg (balance) from account) clause as we delete tuples?
I know how to solve this potential issue. Just don't quite understand why the statement in question works perfectly. I tried testing it out by inserting tuples that have balance close to the initial average. No issues there.
Thank you in advance!

There's even more basic concepts involved
read consistency
A consistent view of data seen by a user. For example, in statement-level read consistency the set of data seen by a SQL statement remains constant throughout statement execution.
data consistency
A consistent view of the data by each user in a multiuser database.
SQL Processing for Application Developers
SET TRANSACTION
Regards
Etbin
something to play with
select rid,x,overall_average,running_average,
       case when case when x < overall_average
                      then 'higher'
                      when x > overall_average
                      then 'lower'
                      else 'equal'
                 end !=
                 case when x < running_average
                      then 'higher'
                      when x > running_average
                      then 'lower'
                      else 'equal'
                 end
            then case when x < overall_average
                      then 'higher'
                      when x > overall_average
                      then 'lower'
                      else 'equal'
                 end || ' ~ ' ||
                 case when x < running_average
                      then 'higher'
                      when x > running_average
                      then 'lower'
                      else 'equal'
                 end
       end average_mismatch
  from (select rid,x,
               avg(x) over (order by rid rows between unbounded preceding and unbounded following) overall_average,
               avg(x) over (order by rid) running_average
          from (select level rid,100 + trunc(10 * dbms_random.normal) x
                  from dual
                connect by level <= 20
RID
X
OVERALL_AVERAGE
RUNNING_AVERAGE
AVERAGE_MISMATCH
1
105
99.65
105
lower ~ equal
2
111
99.65
108
3
100
99.65
105.333333333333333333333333333333333333
lower ~ higher
4
102
99.65
104.5
lower ~ higher
5
108
99.65
105.2
6
87
99.65
102.166666666666666666666666666666666667
7
105
99.65
102.571428571428571428571428571428571429
8
114
99.65
104
9
85
99.65
101.888888888888888888888888888888888889
10
100
99.65
101.7
lower ~ higher
11
100
99.65
101.545454545454545454545454545454545455
lower ~ higher
12
109
99.65
102.166666666666666666666666666666666667
13
88
99.65
101.076923076923076923076923076923076923
14
89
99.65
100.214285714285714285714285714285714286
15
81
99.65
98.9333333333333333333333333333333333333
16
108
99.65
99.5
17
103
99.65
99.7058823529411764705882352941176470588
18
99
99.65
99.6666666666666666666666666666666666667
19
93
99.65
99.3157894736842105263157894736842105263
20
106
99.65
99.65
Message was edited by: Etbin
an example added

Similar Messages

  • Why the html file doesn't change with applet ?

    i am new to java , i get a problem when i am modifying a applet . i recompile it to .class file but did not change its name . and the .html file which use the applet doesn't change with it , it still shows the original style , even when i delete the .class file . it works until i changed the name of the source file and use the different .class file in html . it's troublesome if i need to modify the source file because i must change the name to get it . can you tell me why and how could i avoid this ?

    I am new also & had a similar experience.
    In my case it was aftercompiling and trying to refresh the browser to get it to display the new version of my applet. I got around this by holding Ctrl down and pressing F5 to refresh.
    Also, some of the systems at university cause exactly the problem you describe. Not sure why it should work but we overcame it by placing our files in the JDK folder on those systems & it worked properly. May be worth a try.

  • Created textbox doesn't change with variable?

    I've tried various ways of changing tumbler = 0 to
    if(...){tumbler = 1}, if(...){tumbler = tumbler +1} and so forth,
    but unless I manually change the tumbler value, the text in the
    question box doesn't budge. I've tried moving the tLabel outside
    the onEnterFrame and it just sets to undefined.
    What's going on?

    I seem to be having a problem with inputting new data into
    the textfield, especially in the form of arrays.
    Every time I try to input an array that changes with an
    onenterFrame, it spits out "undefined".
    I can manually change the TLabel.text to display anything,
    such as "Question 3" or "My Dog is an Awesome Dog";
    but when I set up tLabel.text = myArray[myvariable];
    it displays 'undefined'
    I've tried this in an alternative version of the program with
    similar problems.
    When I tried sticking the code for the textfield into an
    onEnterFrame all text disappears entirely.

  • Firefox will not launch in any mode. I cannot open Profile manager to change to another profile. No change with delete and reload of program.

    I've been using Firefox for years. Had this happen once before but was able to open the profile manager and change to a new profile. At this point I can't even do that. Suggestions??

    [[Basic Troubleshooting]] has a "clean reinstall" section at the end that does not require you to open Firefox.
    In any case, you should first take a look at the [[Firefox will not start]] article, which I mentioned in my first post. If that doesn't help, also check out http://kb.mozillazine.org/Browser_will_not_start_up#Windows-specific_problems

  • Catalog doesn't change with connection Update

    When working with each of two reports using Crystal Reports Developer XI Release 2 (11.5.8.826), I am able to use the Set Datasource Location dialog to point my report at a different database (exact same structure); however, when I look at the Properties under each table in the top pane, the Catalog is still the old table.  Is there a report or a Crystal Reports setting that is preventing the Catalog from changing from the old to the new database/connection?

    Please post your SDK development questions to the Developers forum

  • Billing Block status in Sales Order doesn`t change with change in Item Cat

    Hi Experts,
    I have a peculiar problem once I am creating a Contract. In the contract I enter a material with default item category (with Milestone Billing Plan & Billing Block assigned to it),but once I change this Item Category to the other item Category (having No Billing Plan & No Billing Block assigned to it), then the Original Billing Block in the contract for this material does not disappear(the vice-versa of this scenario is not there).
    Request for your help on this issue.
    Thanks,
    Vivek

    HI
    Check controls of document in VOV8 any billing block is assigned for the document.
    Regards
    santosh.A.R

  • "Camera roll" photo thumbnail--doesn't change when delete photo

    I took a, uh, revealing photo and, as normal, it showed up as the thumbnail photo for the "Camera roll" album in my iPhone.
    However, after I deleted the photo, I expected it to be replaced with another photo as the thumbnail for the "Camera roll" album.
    Unfortunately, it's not.
    Luckily, I caught it before anyone saw.
    I supposed I could take another dummy photo to replace it, but this should be fixed.

    I'm sorry, but the fact that you took a potentially embarrassing picture does not mean that anything needs to be fixed.
    Just take another pic and that thumbnail will be replaced.

  • "email usage" doesn't change with reduction in emails

    I made a large reduction in emails but the email usage tab did not show any reduction at all.

    If you deleted emails, did you also empty the Trash folder?

  • My navigation bar address doesn't change with new site loaded

    With the new Firefox 4: if i have multiple tabs open in one window, the navigation bar will only show one of those tab's address for all of the tabs when those should be completely different addresses. i.e. if i look at another tab in same window it has address for first tab, not new one. I'd like to be able to copy and paste the address sometimes. Please help.

    A few possible causes.
    The first is the file that stores details of browsing history and bookmarks is corrupt. For details on how to fix that see http://kb.mozillazine.org/Locked_or_damaged_places.sqlite
    Another possible cause is an add-on interfering with the location bar. To test this, use the procedure in this link - https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    If you are not using the default theme, try switching to it. Some themes can cause this problem.

  • JTable cell value doesn't change with user input

    I'm making a program that uses a custom table model (extends AbstractTableModel). The problem is when I type a value in one of the table cells, then press enter (or click outside the cell), the value goes back to what it was originally. So for example, a cell has "oldvalue", I type in "newvalue", press enter, and now the cell still reads "oldvalue". I figured the renderer would automatically update the cell by calling MyTableModel.setValueAt (...), but maybe I need a listener to do this? let me know. thanks

    alright, well basically I'm making a database manager
    and thought it would be easier to extend
    AbstractTableModel and then do all the queries inside
    the methods instead of listening for events. Second
    thing, I put a debug statement and setValueAt never
    gets called when you type in a new cell value. How
    does it update the cell then is my question?It's your TableModel bug but a much better advice would be that you should use
    DefaultTableModel instead of extending AbstractTableModel. The DefaultTableModel
    is usually more than enough for an ordinary JTable application.
    The simplest and standard way of handling DB data from JTable is updating
    vectors for DefaultTableModel data with your new DB data set. You don't need
    to worry about low-level event firing, cell editor control etc. if you use
    DefaultTableModel. See API documentation of DefaultTableModel closely.

  • How can I delete my icloud account from my iphone, since it doesn't synch with my ipad?

    How can I delete my icloud account from my iphone 4, since it doesn't sync with my ipad mini?

    Go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address (you shouldn't need to verify the old account).  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • PO Release Strategy not changed after deletion of few line items with less

    Subject : PO Release Strategy not changed after deletion of few line items with less Total PO
    Dear Friends
    We have issue with PO Release strategy. We have created the PO. with release strategy  with multiple approvers.  After approval of first approval manager , one of the PO line item got deleted and Total PO value is reduced . The new PO value should have changed the PO release strategy. But it is not changed. Old release strategy only showing in the PO which is wrong. 
    Details of the PO
    PO no 4500000123 with 5 line items Total PO value : 100,000 USD Release strategy : AB
    PO line item 5 deleted. Now total PO value changed to 50,000 USD and the PO release strategy should have been changed to AA but not changed. Still showing PO release strategy AB only.
    Are there any OSS notes available to correct his bug.
    Please let me know if you need more details
    Thanks in Advance
    Thanks
    MVS

    Hi,
    release indicators  change it to 4.It may works. Please explore to all 6 indicators..........
    i.e,
    1-cannot be changed
    2-changable,no new determination of strategy
    3-changable,new release in case of strategy
    4-changable,new release in case of strategy or value change
    5-changable,new release if new strategy/outputted
    6-changable,new release if new strategy or value changed/ outputted......
    And check   Characteristic description and value in Classification  of Release strategies ........
    I hope this will help you. Thanking you.
    Regards,
    Venkat.

  • Numbers 3.2 has changed too much, it doesn't work with my project anymore. How do I revert back to the previous version I was using?

    Numbers 3.2 has changed too much, it doesn't work with my project anymore. 1) The sheet panels used to be on the left hand side and easily reviewable and searchable, but now they are on the top and it's harder to find a specific folder without scrolling (too time consuming), 2) I used to be able to duplicate a folder within my sheet panel window by simply clicking on a folder and hitting Command D, but that doesn't work now so it looks like I'll have to spend even more time to recreate the same tables that used to be easily duplicated, and 3) I can't choose fill colors that matched my project anymore because there are only limited choices available now. And these are only the changes that I'm aware of. I am very disappointed and frustrated. Whatever the motivation was to limit Numbers 3.2, I want the previous version back. How do I revert back to the previous version I was using?

    The sheet panels used to be on the left hand side and easily reviewable and searchable, but now they are on the top and it's harder to find a specific folder without scrolling (too time consuming),
    You can scroll more quickly between sheets if you don't use the left-right triangles, but instead move the cursor up into the bands with the "tabs" and drag right or left.
    Also, if you have a lot if sheets for which you want a quick vertical list, then you can try the following have something like this pop up (showing your sheet names automatically) whenever you hit a keyboard shortcut (in my case shift-command-j):
    This is done via a Jump to Sheet Automator Service (Dropbox download).  To install just doubleclick the .workflow package and (if needed) click 'Download Anyway' in System Preferences > Privacy & Security.
    This will cause a new item to appear in your Numbers > Services menu.  Then, if you want a keyboard shortcut, go here in System Preferences and add one:
    You can rename or remove the service by holding down the option key in Finder and choosing Go > Library > Services. You can also view the AppleScript contaned within the service by opening the .workflow package in Automator.
    This particular service jumps to the first cell of the first table of the sheet you choose from an automatically generated list of all sheets in the current document.
    SG

  • HT204053 I changed my AppleID in System Preferences, but the old ID comes up under iCloud and I get an error box saying my "ID or password are incorrect".  How do I get rid of the old ID which now doesn't work with either my old or new password??

    I changed my AppleID in System Preferences, but the old ID comes up under iCloud and I get an error box saying my "ID or password are incorrect".  How do I get rid of the old ID which now doesn't work with either my old or new password??

    Yes that makes sense, however have you updated it at My Apple ID before trying to change it in your system preferences > iCloud settings, you must do that first.

  • Comcast email doesn't work with firefox 26. I can't get a full inbox, get to my preferences to change, drop downs need to use arrows to get to

    firefox 26 doesn't work with comcast email. won't keep me signed in; won't show whole inbox in either full or lite; won't allow me to get to preferences; drop downs only work with arrows. I could just keep going.
    Earlier this week they worked fine.

    Be sure to delete the login.comcast.net cookie, it is not near the other comcast and xfinity cookies.

Maybe you are looking for

  • Error message for Adobe update helper

    Since upgrading to Lion, I get the following message: You can't open the application Adobe Reader Updater Helper because PowerPC applications are no longer supported. I migrated from a PPC Imac to an Intel based i5 in February. But, this error just s

  • Can't see preview in Canvas

    When I try to change an Effect for my video I cannot see the effect Preview in the Canvas, so I don't see what I am doing/changing. How can I get my canvas preview to work when making effects for clips?

  • Why can't I film after downloading ios 7?

    After downloading ios 7 I suddenly cannot film anymore, i do not know why. Pleas help me!

  • Depreciation on Retirement

    Dear All I have purchased an Asset on 10.04.2008 for Rs. 3,00,000. Now i want to Retire/Sell it on 26.09.2008 for Rs. 2,50,000. How to calculate depreciation for the 26 days. What is the process? Please advice. Thanks and Regards Kanwaljit

  • [SOLVED] Two drive system query

    Hello there I just finished building a new system last week, I'm currently running Ubuntu on it (thought I'd give it another shot, but I NEED Arch back, I miss it). The system has a 60GB SSD and a 1TB SATA drive. I'm wanting to get back up and runnin