How to get average between rows that are null?

I need to get the average between the 2 positive numbers.
Then update the table with the average for those rows that are NULL between the 2 positive numbers.
The average will come (78+89)/2= 83.5. Round it to 84.
Then it will be:
6-4-13       84
6-5-13        84
6-6-13        84
As for 6-9-13 and 6-10-13, those values will still be NULL.
{code}
create table dummy( tmestmp date
,maxtemp number(4,0));
insert into dummy(tmestmp,maxtemp) values(to_date('20130601','YYYYMMDD'),70);
insert into dummy(tmestmp,maxtemp) values(to_date('20130602','YYYYMMDD'),81);
insert into dummy(tmestmp,maxtemp) values(to_date('20130603','YYYYMMDD'),78);
insert into dummy(tmestmp) values(to_date('20130604','YYYYMMDD'));
insert into dummy(tmestmp) values(to_date('20130605','YYYYMMDD'));
insert into dummy(tmestmp) values(to_date('20130606','YYYYMMDD'));
insert into dummy(tmestmp,maxtemp) values(to_date('20130607','YYYYMMDD'),89);
insert into dummy(tmestmp,maxtemp) values(to_date('20130608','YYYYMMDD'),91);
insert into dummy(tmestmp) values(to_date('20130609','YYYYMMDD'));
insert into dummy(tmestmp) values(to_date('20130610','YYYYMMDD'));
{/code}
I need the output to look like this:
Header 1
Header 2
01-JUN-13
02-JUN-13
03-JUN-13
04-JUN-13
05-JUN-13
06-JUN-13
07-JUN-13
08-JUN-13
09-JUN-13
10-JUN-13
70
81
78
84
84
84
89
91
null
null
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production"
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
Suggestions?
TIA.
Steve42

select  tmestmp,
        nvl(
            maxtemp,
            round(
                   last_value(maxtemp ignore nulls)
                     over(order by tmestmp) +
                   first_value(maxtemp ignore nulls)
                     over(order by tmestmp
                          rows between 1 following and unbounded following
                  ) / 2
           ) maxtemp
  from  dummy
TMESTMP                MAXTEMP
06/01/2013 00:00:00         70
06/02/2013 00:00:00         81
06/03/2013 00:00:00         78
06/04/2013 00:00:00         84
06/05/2013 00:00:00         84
06/06/2013 00:00:00         84
06/07/2013 00:00:00         89
06/08/2013 00:00:00         91
TMESTMP                MAXTEMP
06/09/2013 00:00:00
06/10/2013 00:00:00
10 rows selected.
SQL>
SY.

Similar Messages

  • How do I chat between users that are under one .mac/MobileMe family acct?

    How do I chat between users that are under one .mac/MobileMe family acct? We are all under one account, but in different locations, using iChat 4.0.5 and OS 10.5.4. Thank you.

    The only way is to create separate accounts under either AIM or Jabber (for example Googletalk). Then everybody logs into iChat with a different user and you can have full iChat functionality (except encryption which works only if you have different .mac accounts). If some members of your family have already a gmail/googlemail account then they can use this account information to log into iChat if you create a Jabber account with the gmail user information. Otherwise go to www.aim.com, request a screen name and use this user information to create an AIM account in iChat.
    Have fun.

  • How to get the PDF documents that are currently opened in Adobe Reader?

    When a PDf file is opened in adobe reader, how can we know the details of the file which is currently opened.
    If I want a copy the PDF document to get saved on desktop automatically without asking to user, How can I do this in c#?
    If there are many PDF files opened, then also, I have to get all the details of PDF documents  which are opened.
    Thank You...

    Reader Forum http://forums.adobe.com/community/adobe_reader_forums

  • How to get notified of entry that are deleted?

    Hello,
    I'm trying to get notified when an entry is deleted after a certain expiration time. The listener that I've registed gets correctly all the added/updated notification but does not get anything as far as the entryDeleted() is concerned. My guess is that either my listener is not correctly configured or that my expiration schema is wrong. Here is the configuration I'm using:
    <backing-map-scheme>
    <local-scheme>
    <expiry-delay>10s</expiry-delay>
    <flush-delay>15s</flush-delay>
    <listener>
    <class-scheme>
    <class-name>com.cache.MyCacheListener</class-name>
    </class-scheme>
    </listener>
    </local-scheme>
    </backing-map-scheme>
    Any idea why my I don't get notified or why my entries are not deleted?
    Thanks
    Jean

    Hi Jean,
    Your configuration looks right. Eviction happens lazily and on the client thread - did you wait for 15s+ and invoke any cache method (get/put/size etc) to trigger eviction ?
    For example, attached MyCacheListener.main should print:
    entry foo deleted, isSynthetic:true
    null
    Regards,
    Dimitri<br><br> <b> Attachment: </b><br>coherence-cache-config.xml <br> (*To use this attachment you will need to rename 369.bin to coherence-cache-config.xml after the download is complete.)<br><br> <b> Attachment: </b><br>MyCacheListener.java <br> (*To use this attachment you will need to rename 370.bin to MyCacheListener.java after the download is complete.)

  • SSRS 2012: How to get a "Select All" that returns NULL instead of an actual list of all values from a multi-select parameter?

    I have a multi-select parameter that can have a list of thousands of entries. In general, the user will pick a few entries from the list or "Select All". If they check "Select All", I would much prefer that I get a NULL or an empty string
    instead of a list of all values. Is there any way to do that?
    In experimenting with a work-around, I tried putting an "All" label with a null value in the list, but it is ignored (does not display in the drop-down). If I use an empty string for the value, my "All" entry does get displayed, but so
    does "Select All", which is confusing. Is there a way to suppress "Select All"?
    - Mark

    I adapted the following from a workaround posted by JNeo on 4/16/2010 at 11:14 AM at
    http://connect.microsoft.com/SQLServer/feedback/details/249227/multi-value-select-all-parameter-in-reporting-services
    To get a null value instead of the full list of all values when "Select All" is chosen:
    1) Add a multi-value parameter "MyParam" that lists the values to choose.
    2) Add a DataSet "ParamCount" identical to the one used by "MyParam", except that it returns a single column named [Count] that is a COUNT(*) of the same data
    3) Add a parameter "MyParamCount", set it to hidden and internal, then set the default value to 'Get values from a query', choosing "ParamCount" for the Dataset and the one [Count] column for the Value field.
    4) Change the parameter for the main report DataSet so that instead of using [@MyParam], it uses this expression:
    =IIF(Parameters!MyParam.Count =
    Parameters!ParamCount.Value, Nothing, Join(Parameters!MyParam.Value, ","))

  • I want to establish a new and separate Apple ID from my husband's.  We have six Apple devices between us that are aleady associated with our current joint ID.How is this done?

    I want to establish a new and separate Apple ID from my husband's.  We have six Apple devices between us that are aleady associated with our current joint ID.How is this done?

    In order to have a separate 5GB of storage he would need to have his own iCloud account with a separate ID.  You can still share the same ID for iTunes; it does not need to be the same as the ID used for iCloud.
    In order to migrate his phone to a separate account, begin by saving any photo stream photos that he wants to keep on his phone to the camera roll by opening the photo stream album in the thumbnail view, tapping Edit, then tap all the photos he wants to save, tap Share and tap Save to Camera Roll. 
    Once this is done, go to Settings>iCloud on his phone, scroll to the bottom and tap Delete Account.  (This will only delete the account from this phone, not from iCloud.  Other devices still using the account will not be effected by this.)  When prompted about what to do with the iCloud data, choose Keep On My iPhone.  Next, set up a new iCloud account using a different Apple ID (if you don't have one, tap Get a Free Apple ID at the bottom).  Then turn iCloud data syncing for contacts, etc. back to On, and when prompted about merging with iCloud, choose Merge.  This will upload the data to his new account.
    Finally, if there is any merged data in the accounts you will then have to go to icloud.com on your computer and sign into each iCloud account separately and manually delete the data you don't want from each account.

  • Both my husband and I have both downloaded the new IOS 8.2 and now he is getting my text messages that are only addressed to me  He is a 5 and I have a 6.  How can I fix that?

    My husband and I have both downloaded the new IOS 8.2 and now he is getting my text messages that are only addressed to me.  He has a 5 and I have a 6. It is like we are synced together.  How can I fix that?

    Is he getting your SMS messages (green) or your iMessages (blue). If SMS message, go to Settings>Messages and turn off Text Forwarding. If blue, are you sharing an Apple ID? You should each have your own.

  • How can I get rid of numbers that are covering my entire desktop, caused by right-clicking "Clean Up Selection" on an icon?

    How can I get rid of numbers that are covering my entire desktop, caused by right-clicking "Clean Up Selection" on an icon?  The Apple OS X Mavericks blue & green desktop is totally gone.  HELP!

    Here's a screenshot of my desktop, as of a few minutes ago:  http://lewgoodman.com/desktop.tiff

  • How to get master data records that do not have transaction data in a query

    Hi,
    How to get master data records that do not have transaction data in a query output. Can we create a query or any other way to get the master data records that do not have transaction data?

    Hi,
    Create a multiprovider which includes transactional data target and master data info object. Make sure that identification for this master data info object is ticked on both the provider.
    Create report on this multiprovider , keep the master data info object in rows , and now you should able to see all the values which are there in master data info object irrespective of transaction happened or not .
    Next you may create condition showing only zero keyfigure values , ie. master data without any transaction.
    Hope that helps.
    Regards
    Mr Kapadia

  • How do I back up documents that are stored in iCloud to my own hard drive?

    The trouble is, however I search for an answer to this question, I get instructions on how to back up stuff TO iCloud.
    I want to back up stuff that applications like Pages and Numbers are already storing IN iCloud.
    See, I don't want to have to trust iCloud to safely store my documents.  Not unless there are copies somewhere that I can fall back on if (it's really only a matter of when) something goes fatally haywire in iCloud.
    It's easy enough to do with a service like, say, Dropbox, which treats my "cloud-stored" files like they are in a folder on my hard-drive.  So when I run either a local (Time Machine/Capsule) or a cloud (Crashplan, in my case) backup, those files get backed up.  So I have at least three copies of those files - in Dropbox, on my Time Capsule, and on Crashplan's servers.
    So how do I do that with docs that are stored in iCloud?  Apple wants me to store stuff in iCloud - if I have iCloud enabled and want to save a doc to another destination, there are multiple steps I want to go through.  And I'm fine with using iCloud if I'm creating documents that I want to be able to access from my iOS devices as well.
    Yes, I can do that with Dropbox, but it's less seamless than doing it through iCloud.
    But I want my own backups of those files, and near as I can tell, Apple makes that nearly impossible because iCloud does not show up anywhere as a folder that I can access or sort.
    Or does it?  Am I missing something?
    If so, let me know.... if not... is there a solution to this dilemma, or is it just one more aspect of iCloud that Apple has not clearly thought through?
    Thanks,
    --PS

    Right.  You didn't read the post, you only read the title.
    The title came from an earlier step in the process when I was posing a question to the systen.
    The pertinent part of the question is "How to I back up documents that are stored in iCloud" 
    That the destination for the backup is NOT my internal HDD should be clear from the rest of the post.
    And frankly, even if that is where I want to back up to, that would at least give me two copies, at least giving me one duplicate of the stuff on iCloud.
    So please stop wasting my time if you can't answer the actual question: How do I backup content that is stored in iCloud.  The destination of the backup is irrelevant.
    --P

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
    Thanks.

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
              con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
             ResultSet rs = ps.executeQuery();
             rs.last();
             System.out.println("Row count = " + rs.getRow());
             rs.beforeFirst();~Tim
    NOTE: Ugly, but does the trick.

  • I am using an Macbook pro in conjunction with a Time Capsule. I back up all my aperture librarys on it, but how can i view these images that are stored on the capsule please ??

    I am using an Macbook pro in conjunction with a Time Capsule. I back up all my aperture librarys on it, but how can i view these images that are stored on the capsule please ??

    If you want to see what is in a file that is backed up by time machine then you have to restore the entire file. Having said that I have had good experience with Time Machine and individual files... if the file is there then all of it's components are almost for sure there. A way to get around this in Aperture would be to use referenced images. The images then still exist as individual files and can be backed up and restored individually. You would have to do so on a file by file basis though and your album information would still only be saved within the Aperture library.

  • How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"

    How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
    I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
    Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
    I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
    use msdb
    SELECT [JobName] = JOB.name,
    [Step] = HIST.step_id,
    [StepName] = HIST.step_name,
    [Message] = HIST.message,
    [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
    WHEN HIST.run_status = 1 THEN 'Succeeded'
    WHEN HIST.run_status = 2 THEN 'Retry'
    WHEN HIST.run_status = 3 THEN 'Canceled'
    END,
    [RunDate] = HIST.run_date,
    [RunTime] = HIST.run_time,
    [Duration] = HIST.run_duration,
    [Retries] = HIST.retries_attempted
    FROM sysjobs JOB
    INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
    -- CHANGE THIS
    -- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
    ORDER BY HIST.run_date, HIST.run_time

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • How do you change the fields that are displayed on the email preview list after a search?

    How do you modify the fields that are displayed in the mail preview list in the center column of Mac mail after you conduct a search of your email?   All of a sudden the displayed fields changed on me whenever I do a search in mail.   When I have not filtered my email with a search, the default field shown in bold at the top of each message's preview is the "From" field.   However, when I do a search this changes to the "To" field.   Can anyone help?   Thanks, ccarey

    ipicus
    But why would you want this?
    iTunes is responsible for the File Management, let it get on with it, you do your organisation in the iTunes window. And everything you need to do, you can do via the iTunes Window. Want to find the file of a track quickly? Right click on it in the iTunes Window and select Show File: A finder window pops open with the file already selected.
    Regards
    TD

  • How do I see my pictures that are in my aperture library in finder?  I would like I be able to select  photos in finder when I am making photo books online without having to export them first from aperture jinto a new folder. Is there any way to view

    How do I see my pictures that are in my aperture library in finder?  I would like I be able to select  photos in finder when I am making photo books online without having to export them first from aperture jinto a new folder. Is there any way to view and download my pictures directly from finder?

    SamanthaR22 wrote:
    How do I see my pictures that are in my aperture library in finder?  I would like I be able to select  photos in finder when I am making photo books online without having to export them first from aperture jinto a new folder. Is there any way to view and download my pictures directly from finder?  [Emphasis added.]
    The digitization of data has introduced a complexity to our interactions with it that we continue to struggle with.  "Picture" and "Photo" now mean different things in different contexts.  In this case (and in general) defining our terms clearly is the first step towards understanding what we are trying to do.  Understanding is the path that allows us to do it.
    All pedantic, but please stick with me here  .
    You record a set of instantaneous data with a camera.
    That data is processed by your camera and saved to a file.
    The file format is usually either RAW or JPG.
    You transfer those files to your computer, and you import them into the program Aperture (often in one operation).
    From each camera-file imported, Aperture creates a record in its database (called, imho unhelpfully, a Library) and an Image that you see in the Aperture Browser and Viewer.
    Aperture links the Image and the imported file.
    The imported file is called, within Aperture, an Original.
    Every Image has an Original.
    The Image is not the Original.  The Image is what you see in Aperture.
    The Original is a file that is stored on your computer.
    You can make changes to an Image.
    Aperture calls these changes Adjustments.
    Adjustments are saved to another file attached to the record in the database.  Let's call this file the Changes File.
    Aperture uses these two files attached to the record in the database to create the Image.
    Image = Original + Changes File.
    The Image is not a file.
    Because the Image is not a file, it cannot be shared with other programs.  It exists only inside of Aperture.
    In order to share an Image with another program, you must first create a file of the Image.
    You do this by exporting Images ("File ▹ Export ▹ Version" is the command in Aperture; should be, imho, "File ▹ Export ▹ Image").
    You may ask, "Why all the complexity?  Why doesn't Aperture save Images as files?"  The answer is simple:  Images can require less — and in many cases very very much less — storage space than files of Images.  Rather than save a full-size file for every Image, Aperture saves only instructions on how to make that full-size file.  The gain in storage efficiency is huge.  The trade-off is that although your Images are always available to be made into share-able files, you must create those files when needed (which you do by exporting selected Images).
    Here is your question reworded with more precise terms:
    SamanthaR22 might have written:
    How do I access Images in my Aperture Library in the Finder?  I would like I be able to select files in the Finder when I am making photo books online without having to create them by exporting Images from Aperture into a new Finder folder. Is there any way to view and download my Images directly from the Finder?
    No, there is not.  Images exist only in Aperture, and are not accessible for use in other programs.  You must create, for each Image in your Aperture Library, a new file outside of your Aperture Library in order to use it with another program.
    Aperture does allow you to create and save within your Library share-able files of your Images.  These files are called Previews.  You specify the file parameters in Aperture Preferences on the Previews tab.  These files are available to other programs via the OS X Media Browser.  These files are what you get when you drag selected Images out of the Aperture program and drop them on another program or on your desktop (which is part of the Finder).
    HTH.
    —Kirby.

Maybe you are looking for