assistance needed for a complex query

Hi guys

I need your help to write the sql query where I fill in null values when they are in the meantime, as you can see that the same data are for 2 ID... I am able to fill a value zero for id 101 as it's the last with the sql query below... but not able to do the same thing with when null values are between the two...

for id 102, if the value null line si la valeur null ligne date date is greater than or equal to the date of the previous row and fill in with the previous row null value... and if, as in the case of ord = '5' it is identical to the date of the next line, then I need to fill it with the next value of line WD...

Let me know if you need more information;

CREATE TABLE tt (id INT, int DSB, date the t1d, int WD)

INSERT INTO tt VALUES (101, '1','2011-12-20', '484')
INSERT INTO tt VALUES (101, '2','2011-02-12', '444')
INSERT INTO tt VALUES (101, '3','2011-02-12', '444')
INSERT INTO tt VALUES (101, '4','2011-02-14', NULL)

INSERT INTO VALUES of tt (102, '1','2013-05-27', '544')
INSERT INTO VALUES of tt (102, '2','2013-06-02', '544')
INSERT INTO VALUES of tt (102, '3','2013-06-03', NULL)
INSERT INTO VALUES of tt (102, '4','2013-06-10', NULL)
INSERT INTO VALUES of tt (102, '5','2013-07-08', NULL)
INSERT INTO VALUES of tt (102, '6','2013-07-08', '690')
INSERT INTO VALUES of tt (102, '7','2013-07-10', '690')

Select * from tt

SELECT nvl (WD, FINAL_WD) F_wd, * FROM
(
Select *,.
FINAL_WD = (SELECT b.wd
TT b
WHERE b.id = a.id
and b.ord + 1 = a.ord
and rownum = 1
ORDER BY b.ord desc)
TT one
WHERE a.wd is null
) D

Hello

Thanks for posting the sample data.  Be sure to post the results desired from these data.

If ord and wd are numbers, then don't try to insert the strings (for example, '1') in these columns.  It goes same for t1d, but even more.  If t1d is a DATE, then insert only values, not DATE strings such as "2010-12-20'. TO_DATE allows to convert a string to a DATE, or use literals DATE.   All your INSERT statements cause errors on my system because you are using the wrong type of data.

Maybe the analytical LAST_VALUE function can help you:

SELECT id, DSB

t1d

LAST_VALUE (WD IGNORE NULLS) over (PARTITION BY ID.

ORDER BY t1d

WD NULLS LAST

) AS new_wd

TT

ORDER BY id

t1d

;

Tags: Database

Similar Questions

  • Need for the sql query to have several columns in a single coulumn

    Hi all

    I need create the query to have several columns in a single column with several lines.

    Select a.customer_trx_id, a.previous_customer_trx_id
    of ra_customer_trx_all one
    where a.customer_trx_id =: customer_trx_id

    Here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to put them in a single column.

    Say: the foregoing is output
    --------------------------------------------------------------------------------
    a.customer_trx_id a.previous_customer_trx_id

    --------------------------------------------------------------------------------
    123456 87654

    --------------------------------------------------------------------------------

    Need for a single column

    As


    --------------------------------------------------------------------------------
    123456
    87654

    --------------------------------------------------------------------------------

    Please do the needful. Please note that it is not the UNION.

    Thank you
    Abdul

    Hello

    You want a way to confirm that what looks like two rows is really a line?

    Here are three ways:

    (1) count the lines:

    WITH  my_original_querry     AS
    (
         select  a.customer_trx_id || CHR(13)
                          || a.previous_customer_trx_id     as id
         from      ra_customer_trx_all     a
         where      a.customer_trx_id      = 274881
    )
    SELECT     COUNT (*)
    FROM     my_original_query;
    

    (2) in SQL * Plus, have SQL * more count them for you:

    SET     FEEDBACK     1
    
    select  a.customer_trx_id || CHR(13)
                     || a.previous_customer_trx_id     as id
    from      ra_customer_trx_all     a
    where      a.customer_trx_id      = 274881;
    

    (3) implicitly count them with the ROWNUM Pseudo-column

    select  a.customer_trx_id || CHR(13)
                     || a.previous_customer_trx_id     as id
    ,     ROWNUM
    from      ra_customer_trx_all     a
    where      a.customer_trx_id      = 274881;
    
  • Assistance needed for the registration of the application and store the values in a table

    Hello

    Hope that this explanation is not confusing. I explained my application you want in the text below and also attached a skeleton VI + screenshot hoping that he will clarify

    I try to do a VI that does the following:
    1. some code (blue Subvi) runs every 200ms
    2. every 200ms, a random number is generated
    3. the random numbers are stored in a table in intervals of time s 0.8 ("iterations")
    4. at any time, the (blue Subvi) code needs to have access to the random numbers generated in 'the previous iteration.

    To clarify, the iterations are as follows:
    Iteration #1: 0 - 1.8 s
    Iteration #2: 2 - 2. 8 s
    Iteration #3: 3 - 3.8 s

    Iteration #4: 4 - 4.8 s
    ..
    And so on...

    So for each iteration: the blue (Subvi) needs to have access to the random numbers generated in the previous iteration, for example:

    Iteration #1 (0 - 1.8 s): The blue (Subvi) Gets an array that contains only the zero (random numbers are recorded for the first time)
    Iteration #2 (2s - 2 8 s): The code gets an array containing random numbers of iteration #1
    Iteration #3 (3 s - s 3.8): the code gets an array containing random numbers of iteration #2
    Iteration #4 (3 s - s 3.8): the code gets an array containing random numbers of iteration #3
    ..
    And so on...

    At any given time in time;
    -The code gets an array that contains all the random, recorded during the previous iteration numbers
    -Values since before her previous iteration are ignored and not stored anywhere

    Thus, for example, to the #7 iteration:

    -The values during the iteration #6 are made available to the code in the form of a table

    -Values of #1 to #5 iterations have been deleted and not stored anywhere

    It is important that all values since before recording the previous iteration are deleted because they are not necessary because VI actaual will work for a long period of storage of numbers a lot more than I have indicated here

    Screenshot of the skeleton VI:

    I tried to play with the paintings, the structures of the case and the registers at offset, but everytime I try I get something wrong

    The skeleton VI is also attached (Iteration_VI and Code_SubVI)

    Any suggestions?

    Thank you!

    Yes, I agree that you need help.  First of all, you really do need to learn more about LabVIEW - spend a few hours with the tutorials, such as those mentioned on the first page of the Forums.  Oops - links to the tutorials which had been present for years seem to have been moved "elsewhere" with August 2016 LabVIEW community reorganization.  But look for them...

    Here are a few screws that basically implement what I described above (with some minor modifications).  First of all, this is a Top level VI which runs at 5 Hz (200 msec waits).  It starts with an array of 5 elements of 0, then once per second, this is replaced by a table of random numbers generated by the Random 5-table sub - VI 5 elements.  Note that I do not use a loop timed - those who are really designed for LabVIEW RT, but use the simplest functions on the Palette of the timer.

    Can't you see how that works?  The array to initialize on the left begins you with a table of 5 elements of 0.  The Timer inside the loop, it runs at 5 Hz, 'Index' counts 1, 2, 3,... to tell you where you are, and 5 shows you everything that lives on the shift register.

    Now sub - VI Random 5-table is supposed to do the following - if she was called to 5, 10, 15,..., it must return a (new) array of 5 random numbers, otherwise, it must return the array that was passed in.  So if all "works", table 5 shows 0, 0, 0, 0, 0 for the first second, a table at random for the second second (which is not superfluous!), a different for the third random picture second and so on.  I have already said a way to build this, but I chose a slightly different method (equivalent).

    Whenever it is called, a new random element is generated and added at the end of a (growing) random table stored in the shift register.  If size become 5, we send this Random-table-of-5 out through Out table and reset the register shift to an empty array.

    The case by default (when the size is not equal to 5) is shown below - we just return the array of entry to and accumulate new random table in full growth.

    These code fragments extracted from VI.  If you have LabVIEW 2016 (see the "2016" at the top right of the image?  This shows that it is a snippet of code LabVIEW 2016), you can open a blank diagram and drag this image, where magic OR converts it to a VI.  Otherwise, the code yourself and try out it.

    Caution - it is designed to run once.  If you run the program of high level, a second time, you may find that the new Random 5 - table appears to 0.4 ", 1.4", 2.4"(instead of 1", 2 ", 3").  I leave as an exercise for understand you to (a) why he is and (b) fix the code.  If you can't do that, then move an another 3-4 hours with the LabVIEW tutorials (or start playing with this code, edit it in some small way and to understand how it works).

    Bob Schor

  • Assistance needed for the installation of windows server 2008 r2

    Hello users,.

    I am new to this technology of the virtual environment and I need help in installing windows server 2008 r2 on a machine virtual workstation. For it so what are the recommended setting for drivers, no. of processors, amount of RAM, type of CISS or sata... etc to give the best performance on my virtual machine. If possible please provide me details to my knowledge.

    Thanks in advance

    Are you sure that you have installed a Windows Server 2008 R2?

    Because the normal procedure is that after the installation, you will get a prompt to choose an administrator password. Once you are connected.

    There is no additional user created during installation. This only happens when you install versions of Windows desktop.

  • Assistance needed for the scaling of image 1024 x 1024

    Hi all

    I did a VI where I load a 1024 x 1024 BMP file. The BMP is generated by an another VI which is to get a picture of a videostream of my webcam. The raster image gets so grayscale for further processing. My final goal is to make a LV facerecognition

    So when I load the grayscale image I get nothing, but if I use the version 512 x 512, so, I'm able to evolve without any problem.

    I think it's sort of a problem of overflow, but I can't solve...

    Thanks in advance

    24-bit image data are an ara of U32.  If you change the entry in the function Array initialize as a U32 instead of a U8 it will work as long as you notice the depth of the image and use the correct entry to flatten Pixmap.vi.

    I have attached a version that seems to work.

  • Need for Satellite A200-1 g camera assistant software

    Hi all

    I have a problem... I need to find the software assistant camera for Toshiba Satellite A200-1 g
    Can anyone help?

    Thank you!!

    > Can anyone help?
    Maybe, but you should tell us what operating system you are using.

  • A beginner... need for basic assistance

    I see that my camera Sony's AVCHD a 'private' of the file yields that, once seen from within Premiere Pro or prelude of yields. MTS files which can then be swallowed. So far so good.

    My question is help on the most basic level, to help me get started with Prelude. All I want to do is to get a glimpse of these files in the prelude. They keyboard shortcut to place point doesn't seem to be a simple 'I' or 'o' as it is as a prelude - is this true? I'm having trouble getting this simple step to work. Then, I would like to make subclips and I see the number key 1 is the marker for the beginning of a sub-clup, but what is the marker for the out point of a subclip? The interface is nice and this could be an excellent software to learn, but this is easier to do in Premiere Pro and just eliminate the need for Prelude?

    Maybe I need a video tutorial, but also, perhaps the questions I ask here are too basic for a tutorial.

    Can someone please help me with just these questions early so I can see the value in using prelude?

    TIA,

    Ken

    Ken > prelude allow you to ingest your assets (either via Basic linking, copying or transcoding), batch rename them it's make and apply a system of metadata personalized for them. You can't do these things first. In addition, the development of interface on logging, which makes this task easier.

    And out of the points only have meaning in the capture Panel, where you can specify an in or an exit if you do not want the whole media to be ingested. The shortcuts are indeed I and O. You do not change anything that happened first edit as a prelude, so to point on media ingested is not really logical, use subelements markers instead. I and O in prelude is used to set these points and exit markers.

  • 2 drives need for optimization, but will not optimize

    My question is I have two readers who have need of optimization (one is 95% fragmented), the other is 17%.  -J' I try to optimize and nothing happens, why I need help I was wondering if this is the reason why my laptop tonight would not start normally, very slow had to close and restart manually and it was just too slow.  I have 364 GB available on this laptop and save what I had on this laptop.

    I am only using 87.9 GBs and don't know why questions, for a load not only, but who have 4 GB of space and this laptop has begun very well listen to music with games (including online) and now he is lagging badly.

    Can I do to optimize the two discs and get my laptop works better or the hard drive is dying, I know it's under warranty, but when I request assistance from Arrons they help here where I live and always tell me to go to Cortland, NY, which is very far from here.  I tried them to transfer my file but seems that they do not want

    The player is the winretools and the other \\?\Volume{dbf28cb0-6eb5-4cee-a849-bc69492c9c2a}\(one that needs to be optimized

    Hello

    Thanks for posting your query on the Microsoft Community.

    I regret the inconvenience caused to you. I'll be happy to help you with your problem.

    Let's try the steps and check them off below if it helps:

    Step 1: Try to run the utility of troubleshooting system maintenance.

    1. you move your mouse to the bottom right and click search.

    2 choose the setting "tab"; now, type troubleshooting in the search box and click on it.

    3. click on the "Maintenance of Run task" under system and security. System Maintenance Windows opens.

    4. click on 'Next' in the interface of System Maintenance.

    5. Select "Try troubleshooting as Administrator" If you are using another account; Enter the administrator password, then continue.

    Step 2: Virus Scan.

    I suggest you use Microsoft Security Scanner , which will help you to remove the virus from your system and help your system perform better.

    Microsoft safety scanner removes the virus or malware that is on your system and may cause harm to your system.

    To run Microsoft Safety scanner follow the link below:

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Note: Data or files that are infected by malware could be beyond cleaning and must be completely deleted to preserve the integrity of your system, which means that there could be a risk of data loss.

    Reference: Performance & maintenance

    How can I find and remove a virus?

    Let us know the status of the issue. We will be happy to help you further.

    Thank you.

  • Error running on the SIMS 2 and need for Speed Carbon with WIN7 Ultimate 32 bit


    • Error running with the SIMS 2
    • The error that says: the DVD error running is not found
    • I tried to fix it: with XP SP3, VISTA SP2 compatibility mode (I installed the game and I want to play with the compatibility mode for XP with Vista, now I installed WIN7Ultimate 32bits and it doesn't work
    • I already downloaded the latest patch and still work does not correctly...
    With the CNSA, I have the same problem, it starts, but when loads of information to start playing, it opens a window saying the program cannot continue to run, restart the application and the ini.

    Hi fedelovrin,

    Do you have any error message during the installation of the game?
    Is that your DVD player plays all DVDs correctly?
    Could you give us the exact error message that you meet?
    Is the same error message on Need For Speed Carbon?
     
    Since this game is compatible with windows 7, it should work properly without compatibility mode.
    http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/search.aspx?type=software&s=Sims%202
     
    Like you said you used the Windows XP on Windows Vista compatibility mode. Try to use under Windows 7 XP mode also and check.
    You can find more information on compatibility modes in the articles below:
    http://Windows.Microsoft.com/en-us/Windows7/what-is-program-compatibility
    http://Windows.Microsoft.com/en-us/Windows7/make-older-programs-run-in-this-version-of-Windows
    http://Windows.Microsoft.com/en-us/Windows7/Program-Compatibility-Assistant-frequently-asked-questions
     
    Here is the link for the support of the SIMS 2:
    http://TheSims2.EA.com/help/index.php
     
    I hope this helps.

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • whenever I try to load need for speed underground 2, I get this error with vista can someone help me figure out please. __

    Problem event name: APPCRASH
    Application name: need for Speed Underground 2.exe
    Application version: 0.0.0.0
    Application timestamp: 417d8e48
    Fault Module name: need for Speed Underground 2.exe
    Fault Module Version: 0.0.0.0
    Timestamp of Module error: 417d8e48
    Exception code: c0000005
    Exception offset: 001d24c0
    OS version: 6.0.6001.2.1.0.256.1
    Locale ID: 1033
    Additional information 1: a613
    More information 2: 55689aa387c807ab900bd44bfa935768
    3 more information: b5ed
    Additional information 4: d06b121c03be15a74ebeeadaf13834df

    Hi Leinenweaverp,

    Welcome to Microsoft Vista answers Forum!

    I would like to ask you a few questions in order to get a better understanding of this issue.

    ·         Were you able to load this game before and play on it?

    Here are some steps that may help you.

    First of all, I suggest that you perform a clean boot on the computer and install the game and make sure if you are able to load the game and play on it, you can start Windows Vista by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    The following link has steps showing how to perform the clean boot: http://support.microsoft.com/kb/929135

    (1) perform the clean boot (check the link to perform the clean boot)

    (2) enable half the services

    (3) determine whether the problem returns

    (4) enable half of the startup items

    (5) determine if the problem returns

    (6) repeat the steps above until you find out which program or service is causing the issue

    After you determine the startup item or the service that is causing the problem, contact the manufacturer of the program to determine if the problem can be solved. Or, run the System Configuration utility, and then click to clear the check box of the element of the problem.

    Reset the computer to start as usual:

    When you are finished troubleshooting, follow these steps to reset the computer to start as usual:

    1. click on start, type msconfig.exe in the start search box and press ENTER.

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

    2. on the general tab, click the Normal startup option, and then click OK.

    3. When you are prompted to restart the computer, click on restart.

    If the problem persists, I suggest that you contact the manufacturer of the game for further assistance, you can check the link: http://www.nfscars.net/home/index.aspx

    Hope this information is useful.

    Thank you, and in what concerns:
    Swathi B - Microsoft technical support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • What is Adobe flash player needed for

    What is Adobe flash player needed for

    Hi Alison68,

    Welcome to the responses of Microsoft Windows Vista forums.

    Adobe Flash Player is a software for viewing animations and movies using computer programs such as a web browser; in common usage, Flash lets you put animation and movies on a web site. Flash Player runs SWF files that can be created by the Adobe Flash authoring tool, Adobe Flex or by a number of other Macromedia and third-party tools. The Flash Player has been designed to display 2D vector animation, but since become appropriate to create rich Internet applications and streaming video and audio. It uses vector graphics to minimize the file size and create files save bandwidth and loading time. Flash is a common format for games, animations, and GUIs embedded in web pages. Flash Player is available as a plugin for recent versions of browsers web (such as Mozilla Firefox, Opera, Safari and Internet Explorer) on selected platforms. Adobe States that each version of the plugin is backward compatible, with the exception of security changes introduced in Version 10.

    If you need any other calrifications or if you feel that you still need more information, I would prefer that go you through the link below for the best answers.
    http://forums.Adobe.com/community/Flash

    Let us know if you need additional assistance.

    Kind regards.
    Anthony
    Microsoft technical support
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to install need for speed underground without disc2?

    I bought the need for speed 1 of the subway for my PC and tried to install it but unfortunately it asks for a disc 2 that came with my other drive is possible to install it without the disc 2?

    Hello

    I suggest you contact the EA games support for assistance.

    http://support.EA.com/

  • Download Webcam video to need for Email, file TOO big, a FIX for THIS

    I did my little cheesy video, after talking to members of the family that have not seen me for ten years. I made a funny video, but when I tried to "connect" with my Gmail, he say permits. NO DOWNLOAD. So, I tried my new, rarely used live.com account and he tried to load, but the green light of the progression took forever. Then I tried with creativity to post on Youtube.com and it said (1:11:06), I'm like, WHAT's going to take a frickin' TIME to display 7 scarce minutes of fluff. I get hurt on it that I want to connect with my family and all of this could be resolved if I was a millionaire (credit needed for the tutorial). Post people all the time now, there must be a great way to do it. Not particularly warned of the web, but this seems to be a no-brainer. Help me if you can in this 'simple' company to load my video in my family.

    Hello blkenuff,

    Thank you for visiting the Microsoft answers Site.

    You can see the links below for more information about sending attachments in Windows Live Mail.

    http://help.live.com/help.aspx?market=en-us&project=MailFull&querytype=topic&query=WL_Mail_TROU_BlankAttachmt.htm

    In addition, you can also view the link below for more information on SkyDrive, which is a free service that allows you to store and share your files online.

    http://windowslive.com/online/SkyDrive

    Thank you

    Mary
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Need for speed - error: the game has stopped working?

    everytime I open the need for speed, the race. It does not open and says that "the game has stopped working.

    Original title: program compatibility Application Applications App Apps game games Legacy Crash crashes Hang hangs

    Hello

    1. How did you install Need for Speed on the computer?

    2 did you download and install it from the Internet or that you have installed by using the CD/DVD set?

    3. which edition of the game that you are using?

    4. don't you make changes to the computer before the show?

    Please follow the steps below.

    Method 1:

    I suggest you to place the computer in a clean boot state and check if you are able to play the game. You can start Windows Vista or Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

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

    NOTE: after the troubleshooting steps, please return the computer to start as usual (see STEP 7 the above link)

    Method 2:

    Try to update the graphics card drivers and check if it works very well.

    Click on the link below.

    Updated a hardware driver that is not working properly

    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    Method 3:

    Try to reinstall the game and check if it works very well.

    Click on the link below.

    Install a program

    http://Windows.Microsoft.com/en-us/Windows7/install-a-program

    I suggest also please contact the manufacturer of game for assistance.

    http://support.EA.com/

  • Need for Speed Most Wanted does not work in Windows 7

    I already ran it in resolution 640 x 480 with administrator privileges. I also perform a clean boot when doing this, but nothing happens when I launch the game. What can I do?

    I have a PC running Windows 7 64 bit

    Hello

     

    Welcome to the Microsoft community!

    You cannot play need for speed \u200b\u200bMost wanted.

    1. what exactly happens when you try to run the game?

    2 did you do changes on the computer before the show?

    3. are you sure that it is compatible with Windows 7 64 bit?

    You can check its compatibility on the site:

    http://www.EA.com/

    If it is compatible, then I suggest you to install the game in the clean boot and check if the problem persists.

    When the computer starts to boot, programs non-Microsoft will not be started and would avoid any interruption of their share.

     

    Check out the link:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

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

    Note: once you are done with the boot, follow step 3 of section to set your computer to normal startup.

    Note: If in case, you are connected via a connection wireless, and then when you start the System Configuration utility to perform the clean boot, click Startup and Services tab one time and check wireless see corresponding section are checked (enabled).

    For further assistance, I suggest you to get help on the support site for the game:

    http://support.EA.com/

    If you need additional help, let us know and we would be happy to help you.

Maybe you are looking for