How to get the average between the lines are null?

I need to get the average between the 2 positive numbers.

Then update the table with the average for the rows that have NULL value between 2 positive numbers.

The average will come (78 + 89) / 2 = 83.5. Round up to 84.

Then it will be:

04/06/13 84

05/06/13 84

06/06/13 84

Regarding the 13/06/09 and 10/06/13, these values will always be NULL.

{code}

create the dummy (date of tmestmp of the table

(, 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

1 JUNE 13

2 JUNE 13

JUNE 3, 13

JUNE 4, 13

5 JUNE 13

JUNE 6, 13

JUNE 7, 13

JUNE 8, 13

JUNE 9, 13

JUNE 10, 13

70
81
78
84
84
84
89
91

null

null

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production

PL/SQL Release 10.2.0.4.0 - Production

"CORE 10.2.0.4.0 Production."

AMT for 32-bit Windows: release 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)

(order tmestmp).

FIRST_VALUE (maxtemp Ignore Nulls)

(tmestmp order

lines between the 1 suite and unlimited

)

) / 2

)

) maxtemp

modeling

/

TMESTMP MAXTEMP
------------------- ----------
01/06/2013 00:00:00 70
02/06/2013 00:00:00 81
03/06/2013 00:00:00 78
04/06/2013 00:00:00 84
05/06/2013 00:00:00 84
06/06/2013 00:00:00 84
07/06/2013 00:00:00 89
08/06/2013 00:00:00 91

TMESTMP MAXTEMP
------------------- ----------
09/06/2013 00:00:00
10/06/2013 00:00:00

10 selected lines.

SQL >

SY.

Tags: Database

Similar Questions

  • How to get the line object table View

    Hello

    I use Jdev 11.1.1.7

    My requirement is, there are two ways I can get lines in my logic, you're based getFilteredRows (RowQualifier) and vo.executeQuery () - on a specific condition or I should consider first or later...

    getFilteredRows() returns the line [], I need to find a way to make [Row] of the View object properly after ececuteQuery() on the VO... When I use vo.getAllRowsInRange () which returns only a single line, but what iterate the VO even, I see that there is more than one line... How can he get all the range of the VO table?

    Thank you

    You can set the size of the field-1?

    ViewObjectImpl (Oracle ADF model and Business 10.1.2 API components reference)before calling getAllrowsinRange?

  • How to get the line number in the line itself in the Sql query?

    Hello
    I pick up some lines of a sql query. Is it possible to get line number in each line while all lines are read?

    Like this:

    RowNum data1 data2
    1 abc era
    2 NBH ioi

    Yes.

    ROWNUM

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/pseudocolumns009.htm#SQLRF00255

    select rownum, data1, data2
    from yourtable;
    
  • How to get the line blank if the condition does not match

    Hello..

    I have 2 tables
    create table chk1 (no , nm )
    as select 1,'abc' from dual union all
    select 2,'bcd' from dual union all
    select 3,'cde' from dual
    
    
    create table chk2 (no , nm )
    as select 1,'abc' from dual union all
    select 1,'bca' from dual union all
    select 2,'cde' from dual union all
    select 2,'dce' from dual union all
    select 3,'cde' from dual
    There are 2 rows of chk2 table for each record in the table of chk1.
    Off 2 rows if a line is missing any rank must be printed as a blank line

    I wrote the following query but of no use...
    could you help me in this
    select * from chk1 c1,chk2 c2
    where c1.no=c2.no(+)
    Thank you

    Hello

    You can do this:

    SELECT *
    FROM   chk1 c1,
           (SELECT NO,
                   nm
            FROM   chk2
            UNION ALL
            SELECT   NO,
                     NULL
            FROM     chk2
            GROUP BY NO
            HAVING   COUNT(*) < 2) c2
    WHERE  c1.NO = c2.NO(+)
    
    NO     NM     NO_1     NM_1
    1     abc     1     abc
    1     abc     1     bca
    2     bcd     2     cde
    2     bcd     2     dce
    3     cde     3     cde
    3     cde     3     
    
  • Tell me how to get the games are installed in the folder of the game? Have no o/s disc. Computer is refurbished.

    Cleaning disk and accidentally deleted the system restore.

    Hi loralamarche,

    Follow the steps in the article.

    How do I add or remove games in Windows XP

    http://support.Microsoft.com/kb/307768

  • How to get the number of line of a multi-line string

    It seems that this Panel of string does not provide the tool to get the chain line number,

    Does anyone have the same experience?

    so...

    How to get the line number of a variable string?

    Number of lines

  • How can I get the lines for the date between 2 different days

    Hi all,

    How can I get the lines for the date between 2 different days.

    Sample data:
    Table name: Articles
    Title start_date end_date
    Heading1 08-22-2011 2011-09-11
    2011-08-01-2011-09-01 Title2
    Title 3 2011-08-21 08-21-2011
    title4 2011-08-28 2011-09-11

    Result will be:
    Title start_date end_date
    Heading1 08-22-2011 2011-09-11
    2011-08-01-2011-09-01 Title2
    title4 2011-08-28 2011-09-11

    This is my example query:
    SELECT * FROM items WHERE trunc (es.date_start) > = TO_DATE('2011-08-22', 'YYYY-MM-DD') AND trunc (es.date_end) < = TO_DATE ('2011-08-28', 'YYYY-MM-DD')

    but I can not get the expected results. Any help would be much appreciated.

    Thanks in advance

    not read your question properly before...

    Please try this

    Select * FROM items
    WHERE (TO_DATE ('2011-08-22', 'YYYY-MM-DD') between TRUNC (es.date_start))
    AND TRUNC (es.date_end)) OR
    (TO_DATE ('2011-08-28', 'YYYY-MM-DD') between TRUNC (es.date_start))
    AND TRUNC (es.date_end))

  • How to get the difference of current and previous line for a column of the same table?

    Hello

    I have a table where there are 3 rows and say 2 columns only, as below

    Col1               | Col2
    --------------------- |----------------------------------------

    first_flag |  100

    second_flag |  104

    third_flag |  110

    Now, using sql, which accepts a parameter col1, how do I get the bottom o/p

    say that the entry is second_flag,

    output must be

    second_flag, 104, 4 (4 being the difference between 104 and 100)

    If I give the entry like third_flag, the output should be

    third_flag, 110, 6 (6 is the difference between 110 and 104)

    Any help?

    Hello

    Another way is to use the analytic LAG function:

    WITH got_diff AS

    (

    SELECT col1, col2

    , col2 - LAG (col2) over (ORDER BY col1) AS diff

    OF mydata

    )

    SELECT *.

    OF got_diff

    WHERE col1 =: flag_wanted

    ;

    This assumes that the lines are in alphabetical order by col1.  If the order is something else, then use it in the ORDER BY clause analytical.

  • How to get the MAC address of the additional 10G NIC with command-line ILO

    How to get the MAC address of the additional 10G NIC with ILO command line?

    Thank you.

    Hi Bruce,.

    Out of what I can find on this network card is not available for the Mac without an operating system. I recommend get/burning a live CD/DVD of Ubuntu/Linux and run an Ifconfig in there.

    Hope this helps you.

  • The knife tool develops a black line on the objects that I colored using the live paint bucket. How to get the tool knife to stop this and instead of being invisible?

    The knife tool develops a black line on the objects that I colored using the live paint bucket. How to get the tool knife to stop this and instead of being invisible?

    I understand that it is a live paint object you use.

    Try this:

  • How to get the 'DAY' based on the territory of current account held a number between

    Hi all

    Looks like I'm at the end of my intelligence here but how to get the 'DAY' based on the territory of current account with a number between 1 and 7? Oracle has functions to extract the day of the week, but I can't find the other way around.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    SQL> alter session set nls_territory=AMERICA;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    3
    
    SQL> alter session set nls_territory=GERMANY;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    2
    I need a way to know that the number '3' on the database with NLS_TERRITORY = AMERICA means a 'Tuesday' or the number '2' on a database with NLS_TERRITORY = GERMANY means "Tuesday" as well.

    Hope I am clear enough.

    And wish you all a happy new year :)

    Kind regards
    Smail

    Use the format "IW" to get the date of Monday and the format "DAY" to get the "first day of the week. Then compare dates to see if they are identical.

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday    NLS First day of week 1 if day 1 = SUN, 0 if MON
    --------- --------------------- --------------------------
    31-DEC-12 30-DEC-12                                      1
    24-DEC-12 30-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    
    alter session set nls_territory = 'FRANCE';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday   NLS First day of week 1 if day 1 = SUN, 0 if MON
    -------- --------------------- --------------------------
    31/12/12 31/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    

    Or it could be simpler:

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 SUNDAY
            2 MONDAY
            3 TUESDAY
            4 WEDNESDAY
            5 THURSDAY
            6 FRIDAY
            7 SATURDAY
    
    alter session set nls_territory = 'FRANCE';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 MONDAY
            2 TUESDAY
            3 WEDNESDAY
            4 THURSDAY
            5 FRIDAY
            6 SATURDAY
            7 SUNDAY
    
  • How to get the text formatting in the tables

    Dear experts and aid

    For my project, I import an RTF file and then read the data into 3 tables. It works fine when just using the contents of the string of paragraphs. However, the final script should be able to read and to replace the text formatted...
    Why use intermediate tables? Because otherwise I need to swap between two fm-documents (and you can be a part of the book).

    The imported file starts with a certain number of lines separated into two parts by a TAB ("designates a TAB in \x08 FM)
    [[Garneau, 1990 #12]]    »   [9]
    The good article can also be locally as text, e.g. [9]
    Then follow the same (or smaller) number of paragraphs with text formatted like this:
    [9]"D. Garneau, ed., National Language Support Reference Manual (national language Information Design Guide. Toronto, CDN: IBM National Language technical Centre, 1990.

    Is it possible to replace in the body of the function below the next song

      while(pgf.ObjectValid()) {
        pgfText = GetText (pgf, newDoc);
        gaBibliography.push(pgfText);
        pgf = pgf.NextPgfInFlow;
      }
    

    with this

      while(pgf.ObjectValid()) { 
        gaBibliography.push(pgf);
        pgf = pgf.NextPgfInFlow;
      }
    

    Do I need a special statement of the gaBibliography range?
    And how to get the right part of the lines as formatted intro thingy in table gaFmtCitsFmt ?

    Currently, I read in the tables as "strings" (function GetText not shown):

    var gaFmtCitsRaw  = [];                           // left column in processed RTF
    var gaFmtCitsFmt  = [];                           // right column in processed RTF
    var gaBibliography= [];                           // bibliography lines from processed RTF
    // filename is something like E:\_DDDprojects\FM+EN-escript\FM-testfiles\BibFM-collected-IEEE.rtf 
    
    function ReadFileRTF (fileName) {
      var nCits=0, nBib = 0, openParams, openReturnParams, newDoc, pgf, pgfText ;
      var TAB = String.fromCharCode(8);               // FM has wrong ASCI for TAB
      var parts = [];
      
      openParams = GetOpenDefaultParams();
      openReturnParams =  new PropVals();  
      newDoc = Open (fileName, openParams, openReturnParams);  
      pgf = newDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;  // get first pgf in flow
    
    // --- read the temp/formatted citations  
      while(pgf.ObjectValid()) {
        pgfText = GetText (pgf, newDoc);
        if (pgfText.substring (0,2) == "[[") {        // citation lines start with [[
          parts = pgfText.split(TAB);                 // get the two parts of the line
          gaFmtCitsRaw.push (parts[0]);               // Push the result onto the global array
          gaFmtCitsFmt.push (parts[1]);
          pgf = pgf.NextPgfInFlow;
        } else { break }
      }
    
    // --- read the bibliography
      while(pgf.ObjectValid()) {                      // until end of doc
        pgfText = GetText (pgf, newDoc);
        gaBibliography.push(pgfText);
        pgf = pgf.NextPgfInFlow;
      }
      newDoc.Close (Constants.FF_CLOSE_MODIFIED);
    } // --- end ReadFileRTF
    

    The following questions will then be how to change the script of FindAndReplace of Ian Proudfoot for managing text formatted as replacement. I will need to use the copy and paste IMHO...

    Klaus, okay, before pasting, you must assign the TextSelection object at your insertion point.

    // Add a new paragraph after the current paragraph.
    var newPgf = oDoc.NewSeriesPgf (lastPgf);
    var textRange = new TextRange (new TextLoc (newPgf, 0), new TextLoc (newPgf, 0));
    
    oDoc.TextSelection = textRange;
    oDoc.Paste ();
    

    -Rick

  • Re: How to get the Tempo to work properly?

    Hello

    I have problems with the service of Tempo.

    I don't get updates via this application (all the settings of this application are accurate, i.e. "full control"). I know this because there are updates available online to my laptop via the pilot site of toshiba.

    When I installed first Tempo, updates for about a month, I received, and then all of a sudden, no update came through. My firewall is blocking either of this application.

    I tried to reinstall the application, but no change in the situation.

    Does anyone know if ALL updates are available via the website of driver toshiba out tempo? Because, in the month that this service worked, I got an update of the bios, but I recently saw a bios update online and Tempo has not always reports that it is available.

    Any ideas on how to get the Tempo to work properly?

    Thank you.

    I saw in your other thread you have installed SP1 on your Vista laptop.
    There may be some compatibility problems between SP1 and Tempo

    And Yes, as far as I know Tempo bring all available updates!

  • Satellite Pro M50 with Vista: how to get the S-video on the job?

    Hi all

    I have a vista equipped Satellite Pro M50. Does anyone know how to get the S-video on the job? I can't understand.

    Inadvance, see you soon

    Phil

    Did you look in the user manual?
    This doc is always pre-installed on laptop and provides useful information. Also how to connect a TV and use simple notebooks ports.

    A hint; You must use an s-video cable to connect the laptop to the TV.
    Then use the FN + F5 key combination to switch between display devices.
    Sometimes the special s-video option must be enabled on the TV.

    I would recommend consulting the manual of the TV also.

    Good bye

  • How to get the bluetooth turned on the Satellite X 200 - 20 s

    Hello

    Can someone tell me how to get the bluetooth enabled on the X 200-20?

    Thank you

    Hello

    Did you try FN + F8 key combination that switches between the WiFi and BT?
    This should allow the BT on your wonderful X 200.

Maybe you are looking for

  • Reinstalling Windows XP without CD

    Hello I have Windows XP Home edition on my laptop. I think it came to the time where I want to reinstall windows to return some performances! However, as with many computers nowadays, my laptop not came with an installation CD, or any instructions on

  • Win10 on a Touch IdeaPad 330

    Hello After all the problems (years) which is spent by updating Win8 to Win8.1, I wanted to ask you, if I do the update for Win10 without having any stability problems? Thank you!

  • Draw the rectangle on the bottom of the label

    Please helep add me pictures on bottom of the label (size of scree resizable image) I could add pictures but can't make it resizable and can't make it in the background ((()) Bitmap imageBitmap = Bitmap.getBitmapResource ("rectangle.png");BitmapField

  • Problem blackBerry Smartphones with software update on Storm 9500

    Hello I m new here and I have a problem with my Storm. I wan´t to install software was last updated and my phone computer says that there is not enough free space on my storage. But I Don t have data or applications on my phone and it says that there

  • Use the command line to call EX60/C40

    Hello I'm looking to use the command line or xml to call extensions of our EX60 and C40. I want to automate the call made by the devices. We use 9.1 CM and TC6. In addition, if someone knows if it is possible to configure ERA/Hot Dial so when a user