Remove the NULL values and update the value according to the logic

Hello

The problem data

CREATE TABLE VOLA (SRNO, NUMBER, zeroNUMBER, ANUMBER);

INSERTION of REM in VOLA

TOGETHER TO DEFINE

Insert in VOLA (SRNO, ONE) values (1,237.94);

Insert in VOLA (SRNO, ONE) values (2, null);

Insert in VOLA (SRNO, ONE) values (3,203.565);

Insert in VOLA (SRNO, ONE) values (4,170.69);

Insert in VOLA (SRNO, ONE) values (5,113.67);

Insert in VOLA (SRNO, ONE) values (6,93.6);

Insert in VOLA (SRNO, ONE) values (7,82.03);

Insert in VOLA (SRNO, ONE) values (8,66.675);

Insert in VOLA (SRNO, ONE) values (9,63.59);

Insert in VOLA (SRNO, ONE) values (10,61.415);

Insert in VOLA (SRNO, ONE) values (11,60.015);

Insert in VOLA (SRNO, ONE) values (12,58.235);

Insert in VOLA (SRNO, ONE) values (13,57.805);

Insert in VOLA (SRNO, ONE) values (14,56.965);

Insert in VOLA (SRNO, ONE) values (15, null);

Insert in VOLA (SRNO, ONE) values (16, null);

I have to remove the NULL values in column 1, the problem is that the position of the NULL values are not fixed, and it can be any position. If all the lines of the columns are null, then throw it away.

If multiple NULL values are here so I have to do the math as follows to update null with the eigenvalues

1. If the first line is null then take the 2nd value in row and update it.

2. If the lines between both is null then take avg of prev and next value not null and refresh it.

3. If the last value in the column is null, then then take prev and update, in this case last two are null, so I have to take value of prev 14 value line update in

15th and 16th ranks.

I want to put this pl/sql logic, somehow, that I thought have loop and counter aapproach and loops through the elements and check and update.

But always looking for something better before looking to write code. No idea or help will be useful for me.

I * think * you are looking for something like:

WITH VOLA (SRNO, ONE)

AS (select 1,237.94 from all the double union)

Select 2, union null value double all the

Select 3,203.565 from all the double union

Select 4,170.69 from all the double union

Select 5,113.67 from all the double union

Select 6,93.6 from all the double union

Select 7,82.03 from all the double union

Select 8,66.675 from all the double union

Select 9,63.59 from all the double union

Select 10,61.415 from all the double union

Select 11,60.015 from all the double union

Select 12,58.235 from all the double union

Select 13,57.805 from all the double union

Select 14,56.965 from all the double union

Choose 15, null of union double all the

SELECT 16, NULL FROM dual)

GET_VALUES (SELECT SRNO, ONE ACE,

, LAST_VALUE (WE IGNORE NULLS) (ORDER BY SRNO CSA ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS PREVIOUS_VALUE

, first_VALUE (ONE IGNORE NULLS) over (ORDER OF SRNO CSA ROWS BETWEEN 1 SUITE AND FOLLOWS without TERMINALS) AS NEXT_VALUE

FROM VOLA)

SELECT SRNO, ONE, CASE

WHEN IT IS NOT NULL, THEN WE

OTHER CASES

WHEN PREVIOUS_VALUE IS NOT NULL AND IS NOT NULL THEN (PREVIOUS_VALUE + NEXT_VALUE) NEXT_VALUE / 2

WHEN THE PREVIOUS_VALUE IS NOT NULL, THEN PREVIOUS_VALUE

WHEN THE NEXT_VALUE IS NOT NULL, THEN NEXT_VALUE

END

END AS NEW_VALUE

OF GET_VALUES

/

HTH

Tags: Database

Similar Questions

  • How to remove X 64 compatible ACPI value-added general purpose logical device

    Hello

    I made a major mistake and installed the update called:

    TOSHIBA TOSHIBA - other hardware - x 64 compatible ACPI logical value and apparatus for general use

    I have a X 32 Vista system and it is obviously in conflict with my current setup in a very unusual way. To remove the problem, I tried a system restore - but the system had since SP1 is installed and does not have a restore point early enough to remove the update. I also tried to uninstall the update to uninstall Vista a update of the control panel option, - the update is not listed here at all.

    Does anyone know how to remove this update of equipment using methods other than the usual removal of Vista or restore systems? My Device Manager does not list the hardware update x 64-only the x 86 ACPI I expect on my system.

    Hello

    Hmm, I assume that the x 64 compatible ACPI driver has been installed has updated the logical device ACPI x 86 Toshiba added value.

    In case you would remove the logical device of Toshiba x 86 compatible ACPI value added since the Device Manager and I would like to restart the laptop.
    After the new reboot the operating system should recognize the new device and should install the correct driver.

    But I'm not very well if it should be 32-bit or the 64-bit version of Mr. so just try

    Good bye

  • Remove the array without the local Variable element

    I am wanting to know if you can remove an element of an array, the index of the removed part.

    and update the value in the array to not include the deleted part of a more direct way than the following:

    Or, in my program, the table is initialized with some clues that makes the task of removing an element of

    table, the part removed from indexing and updating the table includes only not the deleted part similar to the following:

    (a) is there a way to do this without having to use local Variables?

    (b) I would be so concerned to rid my program of all local Variables? (even those who don't create race conditions)

    Keep the table in a feedback node initialized in the world. Do not imply not objects of façade.

  • Lag() ignore null values performance

    Hello

    I have looked around, but didn't find everybody talks about performance problems specifically with the use of 'IGNORE NULLS' inside of an analytic function of LAG() in a view online.

    This is a cut from the version of my sql, isolated to the question under discussion.

    select * from (
      SELECT /* use_nl (j,gjt,jt) */
         jt.id
        ,COALESCE
          (lag(jt.my_column ignore nulls /* this is the nasty critter */
            ) over (order by jt.order_seq)
          ,0
          )+1 AS start_days
        ,coalesce
          (jt.my_column
          ,last_value(jt.my_column ignore nulls
            ) over (order by jt.order_seq desc)
          ) AS end_days
      FROM  a,bunch,of,tables
      WHERE ...
      ) jt 
    where jt.id = '123456'
    

    If I remove ignores NULL values in the offset, there is no performance problem.

    Last_value() is not affected.

    If I do not use a view inline then performance is very good, although it is no different to explain the plan.

    select ..
    from ...
    where ...
    and id = '123456'
    

    Has anyone come across something like this, or have any suggestions?

    Happy to try to build a test scenario if it contributes to the discussion, but I thought I would just ask the question first.

    Scott

    Scott.Wesley wrote:

    Hello

    I have looked around, but didn't find everybody talks about performance problems specifically with the use of 'IGNORE NULLS' inside of an analytic function of LAG() in a view online.

    If I remove ignores NULL values in the offset, there is no performance problem.

    Last_value() is not affected.

    If I do not use a view inline then performance is very good, although it is no different to explain the plan.

    1. Select...
    2. Of...
    3. where the...
    4. and id = '123456'

    Scott,

    He would not have anything to do with your real problem, since you say that you get different performances during the removal of the IGNORE NULLS clause, but I doubt that you get exactly the same execution plan when online display is deleted these two queries are typically semantically the same.

    If you use the inline view, Oracle cannot push the filter on the ID in the view if the analytical functions partitions not by this ID, because the result will not be the same for the steps: with the online mode, the data is transformed without filtering for the evaluation of the expressions of the LAG etc, and then the filter is applied.

    If you remove the inline view and filter directly, it has a quite different meaning because now the data will be filtered first and then the analytical functions apply to the filtered result set.

    So the case of inline view maybe has to deal with a completely different volume (larger) identical to the variant of view data not online according to the selectivity of the filter - which could explain that the clause "IGNORE NULLS" made a significant difference in performance on this larger volume of data to deal with, but not necessarily.

    Randolf

  • SQL query to restrict null values

    Hello

    I have the following table
    Procurement_id         estimate_end_date          revenue
    
    1                              01-oct-2012                   $1000
    2                              02-oct-2012                   $1500
    3                              01-dec-2012                   $300
    4                              01-jan-2013                    $500
    5                              21-Nov-2013                   $900
    .
    .
    .
    I want only the procurement_ids that have a date of estimated that between 30 and 60 days. and if its estimated finish date is within 30 days, I show that a column monthstoend as 1 and in the 60s would be 2.

    If the output would be something like
    ProcurementId   Monthstoend   revenue
              1                  1              $1000
              2                  1              $1500
              5                  2              $900
    Basically, I want to remove all null values. the query I came was

    Select
    procurement_id,
    (case when (estimated_end_Date - sysdate) < = 30 then 1)
    When (estimated_end_Date - sysdate) between 21 and 60, then 2
    on the other
    null
    end) montstoend
    recipes
    Of
    Table;


    Is there a way to eliminate NULL values in the same query. I know that we can query on top of this request and then to eliminate NULL values, but I was wondering if we can do it in the same query. I use a similar in a much larger request functionality, if want to avoid that if possible.

    Any suggestions?

    Thank you

    Published by: ryansun on September 26, 2012 01:08

    It's not fair...

    select procurement_id
          ,(case when (estimated_end_Date - sysdate) <= 30 then 1
                 when (estimated_end_Date - sysdate) between 31 and 60 then 2
            else null end) montstoend
          ,revenue
    from Table
    where estimated_end_Date - sysdate <= 60
    

    ?

  • The safest way to remove the storage

    I caught a thread several days ago, but I want to start a new. What is the safest way to remove a data store? Poster said that it removes the lun from VCenter. An answering machine for the post explains how VMware and Cormac advise unmount and detach and then they did not, but the lun would be then deleted on the side of the table. Is one better way rather than the other? VMware recommends unmount and detach because the removal of the lun has too much IO in the table? Maybe he's zeroing in on the blocks?

    I have 12 MON I have to shrink, but I obviously can't. I need to re - create. I then am curious about the best way for me to remove hosts. Delete vmfs, or remove/detach. After each of them, both of course would need to have the table to remove guest access to this device/lun.

    According to me, it seems logical to me if:

    (1) remove the data store, if you want to get rid of the LUN (followed by deleting on the side of the table)

    (2) delete the data store, if you want to get rid of its content, but want to reuse the same LUN by recreating a new store of data on it.

    My experience is too limited to comment on the possibility of entering ODA in scenario 2 (followed) by removing the logic unit number, but we can say that scenario 1, simply works.

  • Procedure to remove the LUNS

    I want to remove a LUN of vSphere data store: it is best to remove the LUN of vSphere first, and then rescan all host bus adapters, or remove the logic of the GUI of manufacturers of storage unit number (in my case HP) and then rescan the HBAs in vSphere, or is - not important?

    See you soon

    That's how I would do it.

    1) power off and vMotion virtual all computers, you must first on the LUN.

    (2) remove the LUN of vSphere

    (3) rescan HBAS

    4) enter your San and delete logic unit number (if you want to make a real reformatting/removal of it)

  • Value of the link column remove null values

    Hello

    I use 4.1.1 and I have a column in a classic report that I have configured to post a link to another page in the application. I use one of the IMGS 'edit' and I put the report to show significant like but when I run my page and the value is null, I get always a hyphen and a link (for example. ("' - that is a link) which redirects me to another page. I know a fast method of sale would be to hardcode the html code in the sql code and I know that you should really put an html tag that is similar between your sql. With this in mind are other suggestions of display and img/a for null values.


    Thank you very much

    Alistair

    You can try css:
    #r_contacts_rowview td [headers = "OFFICE_EMAIL"] a [href = "mailto:-"] {}
    display: none;
    }

    He finds the elements of anchoring with mailto value '-' (my null values) in my office_email column. r_contacts_rowview is a static id for a region.
    Display: none to hide items. This works rather graceful.
    Note that this works in IE7/8 your page should be a doctype ( )

    If you don't want a doctype or whatever it is, you can also try jquery of course
    function remove_hyphen_links() {}
    $("td_[en-tetes_=_'office_email']_{a").each (function ()})
    {if ($(this).)} (Text()=='-')}
    $(this) .remove ();
    };
    });
    };

    If I run this onload of my page, I can see hyphens, shortly before they disappear, I don't like too much. Of course, you must bind it to the "apexafterrefresh" - event in your area, as well as the links are also deleted after a partial page refresh (paging).

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • Keeping the description of the table on the evolution and not displaying only not NULL values

    I have the table grouped by MPV and then showing by Fund. I can't get the description section appears for the first Fund and then when he changes nothing only shows funds. When the year changes once again it appears so.
    ex.
    MPV: 2005: 0100AXXXXD
    but when changes in Fund 0100AXXXXD... nothing appears.

    Also, I wanted to not include any funds/years that have the value null. I had the following code in, but it does not prevent null values.
    <? If: SEC_ZERO_INDICATOR! = 0 ? >

    Thanks for any help.

    Need to see your xml data structure. Can you send me the xml and the RTF file to [email protected]? I'll take a look.

    Thank you
    Bipuser

  • Re: How to remove the Package of added value?

    I'm having issues (media buttons no longer work) with the package of added value of Toshiba (TAVP) on my Portege M800.
    I want to update, but I can't do it before removing the old version of the TAVP. When I try to install the new TAVP, I get an error message saying that I need to remove the old version first.

    Problem is, I can't find the TAVP on my "Add/Remove Programs" list The internet said it should be on the list, but it is not. The programs are on my computer.

    They do not seem to be among the programs 'package of added value '. How can I remove the TAVP?

    I use Vista and Win7 long on two laptops from Toshiba. On two of them Toshiba Value added Package is listed in the control panel > programs and features and then you can start to uninstall option.

    I've done this several times. It must be there. He is listed as TOSHIBA Value added Package. Check it out at the bottom of the list under T.

  • Is it ok to uninstall/remove the XP in 2001 and 2005 software updates?

    Is it ok to uninstall/remove the XP in 2001 and 2005 software updates? I have a whole list of updates over the years. Should I just keep piling up? Or they build with each other?

    Original title: is it ok to uninstall/remove the XP software updates from 2001 to 2005? I have a whole list of updates over the years. Should I just keep piling up? Or they build with each other?

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-files/can-i-delete-over-100-foldersfiles-with-a-name/dfa16261-f3d0-4ab7-b519-91631b44b3de

    You can create more free space in C in carrying one of the measures suggested below.

    The default allocation for the restoration of the system is 12% on your C partition is more generous.

    I have them would be reduced by 700 MB.

    Make my computer right click on your icon, and select System Restore.

    Place the cursor on your C drive select settings but this time find the slider and drag it to the left until it shows 700 MB and output.

    When you get to the settings screen, click on apply and OK and leave.

    A flaw that might be useless which is for temporary internet files, especially if you keep no copies on the disk offline.

    Setting the default value is 3% of the walk.

    Depending on your attitude to copies offline, you could bring it to 1% or 2%.

    In Internet Explorer, select Tools, Internet Options, general, temporary Internet files, settings to make the change.

    At the same time, look at the number of days, the story stands.

    The default allocation for the basket is 10% of the disk.

    Change to 5%, which should be enough.

    In Windows Explorer hover over your Recycle Bin, right click and select Properties, Global and move the slider from 10% to 5%.

    However, try to let you become so complete that if it is complete and you delete a file by mistake it will bypass the Recycle Bin and have gone forever.

    If your drive is formatted as NTFS another potential gain arises with your operating system on your C drive.

    In the Windows directory of your C partition you will some uninstall files in your Windows folder in general: $NtServicePackUninstall$ and $NtUninstallKB282010$ etc.

    These files can be compressed or not compressed.

    If compressed text the name of the folder appears in blue.

    If not compressed you can compress.

    Right-click on each folder and select Properties, general, advanced, and check the box before you compress contents to save disk space.

    On the general tab, you can see the winning amount by deducting the size on disk size. File compression is only an option on an NTFS formatted disk partition / partition.

    Select Start, all programs, accessories, System Tools, system information, Tools, Dr. Watson, and make sure the box in front of "Add to the existing rating" is NOT checked.

    This means that the next time that the log is written it will crush rather than adding to the existing file.

    The setting of maximum size by default for Event Viewer logs is too big.

    Reset the maximum value for each log from 512 KB to 128 KB and set it to crush.

    http://support.Microsoft.com/kb/308427/en-us>

    Select Start, all programs, accessories, System Tools, disk cleanup to empty your trash and delete temporary Internet files.

    Also select Start, all programs, accessories, System Tools, disk cleanup, more Options, System Restore and delete all but the last system restore point. Run Disk Defragmenter.

    --

    I quote Gerry C J Cornell - a regular contributor here

    UTC/GMT is 21:33 Tuesday, April 17, 2012

  • Drives hot swap in BIOS not safe to remove the value

    I have a Doc Icy as the docks of the internal disks in a Bay with two power switches front of 5.25 inch front - one for the 2.5 inches dock bay and one for the Bay dock of 3.5 inches.  In the last inserted here readers as well as internal hard drives would come in safe to delete list.  Apparently a Win 7 update fixed the internal drives appear.  Now, even if for the ICY Doc SATA ports are on hot swap in the BIOS, they still do not appear in the delete list safe, which means that the superior policies drive removable section don't appear in the tab Device Manager strategies as they did and still do for USB drives.

    I found here in the forum a few lines of registry added to disable records showing in safe to delete the list, so I wonder if there are a few lines or a tweak for these lines to get two ICY DOC SATA ports to appear in Safe to remove - or y at - it another way?

    Here's the instructions to Remove readers of safe to remove from the other post by Bobby Mikkelson.

    1. click on Start

    2. in the search programs and files box, type the command

    3. under programs, click command prompt , click run as administrator

    If you are prompted for an administrator password or a confirmation, type the password or click on continue.

    4. copy and paste or type each of the commands at the command prompt and press enter after each command

    Reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\msahci\Controller0\Channel0" / f/v TreatAsInternalPort /t REG_DWORD /d 0x00000001

    Reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\msahci\Controller0\Channel1" / f/v TreatAsInternalPort /t REG_DWORD /d 0x00000001

    5 restart your computer to activate the registry changes

    Note: There may be some trial and error to determine the appropriate ports (also called "channels").

    The number of channel indicated in the device maybe Manager may not match the channel number in the registry, you may need to set the value and check the desired effect.

    There is currently no entries like this in HKLM\SYSTEM\CurrentControlSet\Services\msahci\

    In case it is not clear - I WANT that drives DOC ICY appears in safe to remove.

    Win 7 Pro 64-bit

    ASUS Z87.-A.

    All drivers and updates to the operating system to date.

    Hello

    Your question is better suited for TechNet where experts on this platform will help you better, please post your request in the Sub forum:

    https://social.technet.Microsoft.com/forums/en-us/home

    Hope this information helps, for assistance please answer.

  • Manual search - when start us research by removing the value manally, same results for future research in the next page.

    Hi guys OAF.

    Created a page of manual search with several buttons below. After entering search criteria and click on the first button, it shows the records in a separate page where I perform trade operations. The second page, I have a "back to the main search" link that takes me to the first page of search.

    Now, if I remove the value of any field of text input by clicking X mark the end of the field, or pressing the button remove the key board and try searching again, same values are to come in the next page as if I did not remove the value.

    Data on the next page is mainly with the help of setWhereClause. And here is the code I wrote.

    public void issueQuery (String OrderNum)

    {

    If ((OrderNum! = null) & & (!("".)) Equals (OrderNum.Trim ()))

    {

    setWhereClause ("ORDER_NUMBER =: 1");

    setWhereClauseParams (null); Always reset

    setWhereClauseParam (0, OrderNum);

    }

    executeQuery();

    }

    Please advice, what has gone wrong or its something Oracle behavior?

    Thank you

    Bideau

    I got the answer, it is resolved after the setwhereclause reset each time.

  • the non-null values insert select

    Please could you help me on this:

    INSERT INTO new_table (ID, hobby, country, internal_id, cat)

    SELECT ID, hobby, country internal_id,

    Max (CASE cat WHEN = 'ben' THEN 1

    WHAT cat = 'ale' THEN 2

    WHAT cat = 'inf' THEN 3

    WHAT cat = "cad" THEN 4

    WHAT cat = 'juv' THEN 5

    WHAT cat = 'sen' THEN 6

    WHAT cat = 'teacher' THEN 7

    END)

    Ancienne_table GROUP BY ID, hobby, country, internal_id;

    the lines on ancienne_table have duplicates regs as follows:

    IDCountryHobbyInternal_IDCAT
    1OmanRugby Union63180Juv
    1OmanRugby Union63180Teacher
    1OmanRugby Union63180Juv

    the request requires the output as follows:

    IDCountryHobbyInternal_IDCAT
    1OmanRugby Union631807

    because cat = 'juv' (5) is less cat =' teacher (7).

    all columns are not null and the primary key of the new_table is ID + hobby

    The script displays the following output:

    01400 00000 - 'impossible to insert NULL into (%s)' because does not recognize the function max.

    Thanks in advance.

    Kind regards.

    Actually there are values not in the range of cat. There is an error in the old data table.

    I proceeded to remove the lines out of reach in the cat because column that are not relevant in this case.

    The parameters I use Oracle are:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    PL/SQL Release 11.2.0.1.0 - Production

    "CORE 11.2.0.1.0 Production."

    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    Thank you very much. You are so helpful.

    Kind regards.

Maybe you are looking for

  • Slow down the AirPlay - Apple TV does not work properly :-(

    Hello. I had a problem of airplay slow play movies, DVD or any video support 720 p or higher on my old one year Apple AirPlay and new Panasonic TV. I've been through problem solving, including restore and optimize my Telus router (which has 2.5 Mbps

  • DroidLight on the Xoom

    Is it possible to make the Droid app light works honeycomb / on the Xoom? It is useful on my phone, so I figure that it would be useful on my Tablet too.

  • HP Probook 4320 s Windows XP SSD support?

    Hi guys I have a HP Probook s 4320 under Windows XP Pro SP3, and I plan to spend a traditional HARD drive to an SSD hard drive.  I was wondering my HP Probook s 4320 would support an SSD and Windows XP even recognize it? Any advice or assistance woul

  • USB-6218 for PC transfer speed

    Hi guys,. I hope to be able to taste 10 channels 10 Hz for about 1 hour, in Labview 8, on a relatively new core dual desktop PC. First, I tried an Agilent34970a and concluded that, even if she can continuously scan quickly enough, GPIB in Labview tra

  • Report on the last access of VM

    I'm looking for a report that can leave data such as when was the last time the VM has been consulted and for how much time a virtual machine was turned off.