Need to get average numbers > 0

I need to get the average of the 2 numbers POSITIVE, non-null.
I still want to keep the NULL value in the column. I want to update the table
where NVL (temp_s,-1) = 0
Here's a sample:
< code >
create the dummy (MY_ID NUMBER (5.0) of the table)
C_DATE DATE
TEMP_S NUMBER (4,0));

Insert into dummy (my_id, c_date, temp_s) values (41, to_date('20130114','YYYYMMDD'), 32);
Insert into dummy (my_id, c_date, temp_s) values (41, to_date('20130113','YYYYMMDD'), 0);
Insert into dummy (my_id, c_date, temp_s) values (41, to_date('20130112','YYYYMMDD'), 57);
Insert into dummy (my_id, c_date, temp_s) values (41, to_date('20130111','YYYYMMDD'), NULL);
Insert into dummy (my_id, c_date, temp_s) values (56, to_date('20130110','YYYYMMDD'), 59);
Insert into dummy (my_id, c_date, temp_s) values (56, to_date('20130109','YYYYMMDD'), 0);
Insert into dummy (my_id, c_date, temp_s) values (56, to_date('20130108','YYYYMMDD'), 51);
Insert into dummy (my_id, c_date, temp_s) values (56, to_date('20130107','YYYYMMDD'), NULL);

< code >
I want the output to be:
< code >
41 14 JANUARY 13 32
41 13 January 13 45 < = this update based on the day, before and after.
41 12 JANUARY 13 57
41 11 JANUARY 13 NULL
56 10 JANUARY 13 59
56 9 January 13 55 < = this update based on the day, before and after.
56 8 JANUARY 13 51
56 7 JANUARY 13 NULL
< code >
TIA
Steve42

Hello

Here's one way:

MERGE INTO     dummy     dst
USING   (
         SELECT  my_id, c_date
         ,         CASE
                     WHEN  temp_s <= 0
                 THEN  CEIL ( ( LAG  (temp_s) OVER ( PARTITION BY  my_id
                                                              ORDER BY       c_date
                                    )
                              + LEAD (temp_s) OVER ( PARTITION BY  my_id
                                                              ORDER BY       c_date
                                    )
                        )
                      / 2
                      )
                  END          AS temp_s
         FROM    dummy
     )          src
ON     (    dst.my_id     = src.my_id
     AND  dst.c_date     = srC.c_date
     )
WHEN MATCHED THEN UPDATE
SET     dst.temp_s     = src.temp_s
WHERE     dst.tEmp_s     <= 0
;

Depending on what my_id role in this problem, and what is unique, you may need to tweak it a bit.

Tags: Database

Similar Questions

  • I have several versions of InDesign 6 on different MACs and need to get the serial numbers for them. How can I get them?

    I have several versions of InDesign 6 on different MACs and need to get the serial numbers for them. How can I get them?

    If they were recorded at Adobe.com, sign in under the adobe ID, a number will be there.

    If they were purchased in the box and unregistered, you need to find the number in the box (usually on the sleeve)

  • Get page numbers to properly on distributions of left-right

    I have a document with 5 pages of "forematter": a the title Page, that I have no page number as a section, and then a section 2 section containing the copyright page, dedication page and two-page table of contents, page numbers in Roman numerals.

    Then the meat of the book as a 3rd section, the page numbers in Arabic numerals in standard.

    Here are my pages window:

    Screen Shot 2016-02-02 at 10.44.09 AM.png

    I need to get somehow '1' to the left page of a spread with '2' and the rest pages reflow accordingly, given that the current Setup gives me the page numbers in the wrong place, as you can see below.

    Screen Shot 2016-02-02 at 10.34.47 AM.png

    An odd page number must be on the right side of a spread in LTR languages, as is standard. To empty pages, you will need to insert a blank page.

    I do not understand your screenshots, why the margin guide in the spine not showing space for the spinal column and that he should?

  • There is a big tile on my footer to browser and I need to get off it.

    After the update of 40.0.3 there is a large tile at the footer of my browser and I need to get rid of him. No idea why this tile appeared?

    Thank you! It was a Citrix plugin causing problem...

  • I recently installed Firefox 10 but it is not compatible with some application that I have to work. I need to get back to 9 Firefox. Where can I find to download? in English

    I recently installed Firefox 10 but it is not compatible with a client app, that I have to work. I need to get back to 9 Firefox. Where can I find to download?
    I'm working on a laptop Packard Bell with XP.
    Thank you.

    [email protected]

    Hey wordsontime,

    There are many benefits to the latest version of Firefox. You may want to consider the old version running on a USB key with PortableApps. This way you will always be able to run the latest version for your daily activities.

    If you want to roll back to a previous version of Firefox, just take a glance section of the Knowledge Base install an older version of Firefox.

    Hope this helps!

  • I need to get the bookmarks from a backup hard drive that the system failed on. were can I find the file/folder of bookmarks?

    I need to get the bookmarks from a backup hard drive that the system failed on. were can I find the file/folder of bookmarks?

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729 .NET CLR 3.0.30729; NET4.0C; Media Center PC 6.0)

    Bookmarks are stored in a file called places.sqlite in the profile folder.
    To find out where the profile folder, see http://kb.mozillazine.org/Profile_folder_-_Firefox

  • Equium EA60-156: need to get a new motherboard

    My computer will not start. Need to get a new motherboard for it. No idea where to find it at a reasonable price and how much?

    Hello

    All compatible parts and supported as motherboard, you can order the Toshiba service partner in your country. You can also ask for the price.

  • How can I get negative numbers on my spreadsheet of numbers to be displayed in red.

    How can I get negative numbers on my spreadsheet of numbers to be displayed in red. The only thing that I can find in the menu turns formatting all the red cell. Not what I want

    Use the conditional formatting.

    Select the range of cells you want to format, and then open cell formatter:

    Now click the button of "conditional highlighting:

    Now click on the button «Add rule...» » :

    Now choose the rule "less to" a value of zero and choose the selection of red text to highlight

  • Helps identify the type of SSD memory please - need to get data from dead Air

    I just had a problem with a model of Macbook Air 11 '' 2011. He's stuck in the loop start-up chime. Reset SMC and PRAM do nothing, cannot boot from the external drive or boot in target mode. I have an appointment with Apple to get it looked at. However, research I've done so far suggests be corrupted RAM, or fried logic board. Anyway, the important thing for me to do now is get the data off of it.

    Normally, I do regular backups, but it happened during a stay. 10 days to 2 weeks holiday and all the photos and video of holiday have been about it. I need to get this, regardless regardless of the fault of the laptop. I would like to get a USB for the SSD enclosure and just after the Council about what I should look for before you buy. I have used to treat drives 2.5 "for this sort of thing, but I have to get something specific for the SSD that came with my MacBook Air?

    Help is very appreciated. Literally, this / has been wonderful and I couldn't have lost memories of a more important time. Details included below Air...

    See the following: http://eshop.macsales.com/item/OWC/MAU3ENVOY11/

    Their phone number is at the top of this screen - I would recommend calling to check which is the correct case for your model.

  • Attack of Zaq 140813 need driver for keyboard numbers, HP Mini 110-3530NR, Windows 7,

    Attack of Zaq 140813 need driver for keyboard numbers, HP Mini 110-3530NR, Windows 7

    Dear Brigitte,
    Yesterday, I tried to connect my keyboard to my mini HP numbers, but it did not work.  I am sure that the problem is the driver, as I was able to connect to my HP laptop with Vista, without any problem.

    The keyboard is a keyboard of ten Note X TK01 USBM.  In the back are the words "Arvel TK01 = USBM Ten keyboard, S? N 990500424, made in China.

    You can locate a driver for me so I can install it on my HP Mini?
     
    Thank you

    Dear Brigitte, it was one of those anomalies that solve themselves.  After trying several times, I found the pad of numbers worked so I replugged it it after that I received the error message.  Second time around, it works fine.  JC

  • HP DV2000 Clubhouse: Clubhouse DV2000 HP - REALLY needs TO get BACK ON MY OLD LAPTOP!

    Hello - I would be extremely grateful if someone could hep me, please!

    I have not used this particular laptop for years, but I desperately need to get back to recover some files.

    The laptop seems to work very well, but when I turned on a black screen appears with password enter in blue - it doesn't look like the page normal Windows that I can remember. It seems that it is in some kind of safe mode or something.

    I don't know what is this password. If I hard enter too many times he said disabled system [05745]

    Can someone please advise?

    Thank you very much

    You are the very welcome.

    The only other suggestion I can offer is to try this release for generic Phoenix BIOS code.

    quxfffl

  • I need to get a certificate to continue using WI - FI how di I find the certificate?

    I need to get a certificate to continue using WI - FI how di I find the certificate?

    Original title: WiFi problem

    Hello

     
     
    1. who is the operating system installed on your computer?
    2. What is the exact error message that you receive?
    3. who is your Internet service provider?  Have you tried to contact them about this?
     
     
    Follow the steps mentioned below and check if that helps.
     
    Method 1: You can check if the router is configured for WPA and WPA2 connection:
    a. If the router is configured for WPA and the configuration of your wireless network on your computer must be configured the same way. That is to say, WPA.
    (b) if the router is configured for WPA2, then the configuration of your wireless network on your computer must be configured the same way. That is to say, WPA2.
     
     
     
     
    Method 2: You can manually disable authentication IEEE 802. 1 x. Subsequently, re - enable authentication IEEE 802. 1 x and see if the problem still occurs.
     
    See: If you use a NETGEAR wireless router, you can follow this link:
    Unable to connect to the network: Validation and certificate in Windows XP and Vista errors
    http://support.NETGEAR.com/app/answers/detail/A_ID/7334/~/unable-to-connect-to-network%3A-validation-and-certificate-errors-in-Windows-XP
     
     
     
     
     
  • If I buy and install Windows 7 Home premium is automatically change my laptop a touchscreen screen or do I need to get a screen special hardwear?

    If I buy and install Windows 7 Home premium is automatically change my laptop a touchscreen screen or do I need to get a screen special hardwear?

    monitor you need to buy a touch screen, win7 it turn not into one!

  • need to get the Service Pack 2 and 3 for XP home

    Recently installed new h-drive. Re-installed XP Home with services Pack 1 a. I need to get the Service Pack 2 and 3, but none of Microsoft download sites will work for me. What should I do to fix this?

    You don't need sp2 (which is a chance, l because the sp2 link no longer works).

    Download sp 3 here: http://www.microsoft.com/en-us/download/details-b.aspx?id=24

    First read this: HOW TO get WinXP SP1 or SP2 fully patched after a 'clean install': http://groups.google.com/group/microsoft.public.windowsxp.general/msg/a066ae41add7dd2b

  • HP try to send me to this day that she wouldn't, take, says I need to get the Version of the Net Frame work V 2.050727, said to communicate with my editor about Apporiate version of the Net frame work.

    You need to get the update, it must get The Net Frame work V 2.050727, where can I get coming up to date, for the calculation.

    Hello

    1. do you use the 64-bit or 32-bit operating system?

    2. update you are trying to install HP?

    I suggest you to perform Windows updates.

     
    If there is an update for .NET Framework, I suggest to install the update and try to install the update from HP.
     
     
    To run Windows update manually, follow the steps:
     
    a. go to the Windows Update site. Open Internet Explorer and go to tools, Windows Update.  You must use Internet Explorer; using other browsers will result in an error message.
    b. click 'Use Administrator Options' in the menu on the left. Once the Administrator Options screen, choose to search the Windows Update Catalog under "update multiple. operaing system."
    c. install the Active X control if requested. On the screen type catalog Microsoft Update in the operating system you want updates in the area of research (for example, Vista or XP).
    d. click 'Add' next to each update you want to install. Updates will be added to your shopping cart.
    e. click on "View cart" in the upper right corner of the screen when you are finished selecting your updates. Make sure everything you want is here, and then click 'download '. In the "Download Options" popup that appears, choose where you want to download the files. A progress bar indicates the status of the downloads.
    f. navigate to the location where you downloaded the files. Double-click the files to install. You will probably be asked to restart your computer after installation is complete.
    g. to download updates for use on another computer, which is not connected to the Internet, for example, save files on removable media such as a USB drive or a disk and load the media on the computer. Double-click the files and install as you would if you downloaded them.

    If there is no update for .NET Framework, try to download and install the update manually from the link below.
     
     
    Microsoft .NET Framework Version 2.0 Redistributable Package (x 86):

    http://www.Microsoft.com/en-US/Download/details.aspx?ID=19

    I hope this helps.

Maybe you are looking for

  • DeskJet 2540

    I have two desktops in our small office, both related to a wireless printer.  They have always worked great until today, when I can't print anything one of desktop computers.  In a Word or Excel document, it always says, "not responding".  Printing f

  • Organize all in curls

    Hello guys,. I'm working on a project that I have to use a lot of While loops since I have a lot of things going on parallel. However, I think it's a little disorganized since my program am too big and it's a little difficult to find specific things.

  • Error message "HPSF.exe has stopped working" whenever I have open hp support assistant HP g6

    I have thought honastly this laptop couldn't be worse. I downloaded the latest version of the hp support assistant after resinstalling windows and all the other stuff of hp and when I try to get updates from hp it comes up with a error message saying

  • Windows blocks all a few minutes after the last round of updates and latest installation of IE

    I ran the last round of updates of security and the upgrade of IE over the weekend. Now by PC crashes every 4 or 5 minutes. All I can do is to draw power and restart. the problem seems to happen more when messenger, IE, or firefox are used. Before I

  • Windows XP does not work with Google Chrome

    I have Windows XP. When I connect to Google Chrome, I get this message. "Google Chrome requires Windows XP or later. Some features may not work. "(some features do not work). How can I get GC to recognize Wn XP? I also have problems with Internet Exp