Update, one of the two columns based on a condition

I have this example table:

Lead_ID

Mailed_Date

Campaign of

Model

MPI

MP2

100

August 2, 12

Travel_Check

US_Air

null

null

200

August 2, 12

Travel_Check

US_Air

1099

null

MP1 and MP2 columns represent mailpiece_IDs (marketing mail that was sent).  MP1 is the first piece in the mail and MP2 is the second room that receives mail. Here Lead_id 100 received no mail and Lead_id 200 received the first piece.

I want my update to allow me to update MP1 IF MP1 is null, but if MP1 is worth, I want MP2 to update. So if I update with a new post 2000 article ID the result should look like this after the update.  Lead_ID 100 received a piece of mail, and 200 Lead_ID received two parts:

Lead_ID

Mailed_Date

Campaign of

Model

MPI

MP2

100

August 2, 12

Travel_Check

US_Air

2000

null

200

August 2, 12

Travel_Check

US_Air

1099

2000

I tried this case and I thought that maybe I could choose the field with COALESCE, but which doesn't seem to work.   Can anyone help?

Hello

Here's another way to do it:

UPDATE yourtable

Mp1 SET = NVL (mp1, 2000)

mp2 = NVL2 (mp1, mp2 2000)

WHERE LESS (mp1, mp2) IS NULL

;

In any case, there are 2 columns that could be changed, so you should have 2 columns listed in the SET clause.  It does not matter that one or these columns will be always equal to itself.

Tags: Database

Similar Questions

  • Conditional formula using one of the two operations

    How to create a conditional formula where the results are a choice between two formulas based on the cell to two cells has a value greater than 0?  More specifically, I have to add value in a cell (in the column headed "added amount") to a cell in a column of the running totals if the value of this cell is greater than 0, or subtract the value of a different cell (in the column headed "amount withdrawn") in the same line, if the value of this cell is greater than 0.  Only one of the two will have a value in a given line.

    Hi George,.

    If you only have a value in a column, then you have even a logical formula. You can do this:

    A2 is an input value, it could be called "balance forward".

    A3 is filled down.

    Quinn

  • How to upgrade one of the two lines in double

    I use 11.2.0.3.0

    Is it possible using a CASE statement to find the rows that are double and one of the two lines was updated so that they are all unique?

    What I get is something like this

    Col1 Col2 COL3 COL4 Col5

    1

    1111
    11111
    22222
    22222
    33333
    33333
    44444
    44444
    55555
    55555

    I would change one of the columns in the two lines that makes the unique lines like this

    Col1 Col2 COL3 COL4 Col5
    11111
    12111
    23222
    24222
    35333
    36333
    47444
    48444
    59555
    50555

    Hello

    I don't see how a CASE expression would contribute to this problem.

    In your original message, you said you wanted to update the table, in other words, to permanently change some of the values stored in the table.

    In response, #2, looks like you want to change what is in the table, you just want to replace by new values for col2 in this query, without permanently changing table.  You can do this by using the ROW_NUMBER right in the query, when you thought using a CASE expression.

  • How do you apply Blur to only one of the two duplicate layers?

    Hello everyone

    I have two layers of dynamic object to a panoramic photo, which is a duplicate of the other and returned vertically.

    I would like to apply Blur to the inverted layer, so this step appears as a reflection of the other layer.

    However, when I apply the blur to the image reversed in its .psb document window, the blur effect ends on the two layers.

    Why the blur apply to two separate smart objects and how could possibly apply Blur to only one of the two double layers?

    Please advise me.

    Thanks as always,

    EAD

    Even if you see two separate layers, Photoshop is not to see them in the same way. When you using duplicated layer (Ctrl/Cmd + J) command, which tells Photoshop to create clones SO double layer sets SO. Update content on one of the 2 cloned layers will take into account changes to another. As you modify the content of a layer of cloned SO that change is automatically reflected in the other. As noted above, the solution is mentioned to apply the blur as a dynamic filter without changing the content (do not double click on layer SO): with SO layer selected in the layers panel, go to filter > blur > Gaussian blur.

    To cite only in case you need this option: you can duplicate the layer SO without cloning to help: command of new dynamic through copy object . In this case you can apply changes to the .psb file you make and modifications will not reflect to another (parent) layer of SO. In this case, disadvantage is that you can't quickly Exchange content on the two SO layers when creating clones SO you can overlay.

  • I can't send mail to one of the two accounts of e-mail with the outgoing server.

    Recently, I was unable to send an email to one of the two accounts which are the two aol. One of them is netscape. They both use the same outgoing server 'smpt.aol.com' I've tried the suggestion to remove the password on behalf of netscape (the one I can't send). Now I get a 5.7.1 sender address rejected. I'm sure this is a settings problem and probably a dealing with passwords, but I just can't solve. Help!

    I checked both accounts and servers as you suggest. The first time he asked me, he said that have been rejected. When I pressed try again, it has been accepted, and now everything seems to work fine. Thanks a lot to you two. I really appreciate it.

  • Combine the two columns of text

    I have two columns of text (say that name is a column and the name is the other)

    I would like to combine the two columns for the text of these two columns are in a column. (First name and last name in the same column)

    Is this possible? If so is there a tutorial somewhere?

    Hi Danielle,

    The & (concatenation operator) is your friend.

    Formula in D2 (fill down)

    "B2 &" "& C2.

    & joins elements into a single string.

    "" inserts a space.

    Kind regards

    Ian.

  • How can I printscreen, only one of the two screens I use now?

    I work with two screens and when I try to printscreen the computer takes the two images on the screen and print, making the really small screen images to the point that they are almost impossible to read.
    I want a pint only one of the two screens.

    Hello

    Try the capture tool:

    How to use the Windows Vista Snipping Tool
    http://www.bleepingcomputer.com/tutorials/tutorial135.html

    Use capture tool to capture screenshots
    http://windowshelp.Microsoft.com/Windows/en-us/help/1337cdba-52a2-4704-ad4d-2d7bace605b41033.mspx

    How to take screenshot with the capture - simple tool
    http://Lifehacker.com/228885/Windows-Vista-tip--take-screenshots-with-the-Snipping-Tool

    Cup - best tool screenshot screenshot
    http://desktoppub.about.com/od/screencaptures/IG/Snipping-Tool/Snipping-Tool.--0k.htm
    http://graphicssoft.about.com/b/2009/05/15/using-the-Snipping-Tool-in-Windows-Vista.htm

    How to take a screenshot with the tool captures of Vista
    http://www.WikiHow.com/take-a-screenshot-with-the-Snipping-Tool-in-Vista

    Use the Windows Vista Snipping Tool to take screenshots
    http://www.tips4pc.com/articles/Windows%20Vista/use_the_windows_vista_snipping_t.htm

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • How to choose the slot one of the two bunk?

    How to choose the slot one of the two bunk?

    Select the two points to cross the selection with the open selection tool, and then clear the high point on the page by holding shift and clicking on it.

    or vice versa. Select the high point of the page first and then select now shift. the high point of the page désélectionnera.

  • using outer joins if the two column is null? Use only (+)

    Hi all

    create the table xxc_tr_num (tl_number number, tr_no number tl_no_id);

    insert into xxc_tr_num values (123,100,222);

    insert into xxc_tr_num values (124,100,333);

    create the table xxc_od_tab (tl_number number, tl_id number);

    insert into xxc_od_tab values (123,001);

    insert into xxc_od_tab values (null, null);

    create table xxc_oth_tab (name varchar2 (10), number of tl_id);

    insert into xxc_oth_tab values('abc',,001);

    insert into xxc_oth_tab values (null, null);

    Wait it out put

    tr_no tl_no_id name

    100 222 abc

    100 333

    using outer joins if the two column is null? use only please of outer joins

    And I tried to use outer joins on both tl_id column but not get values and I use have County (tr_no ) > 1

    Rajesh123 wrote:

    Thank you Kiss it is not possible to use having clause?

    You need to understand the functioning of the group. If you will not be asked this question.

    Check this box

    SQL> select tr_no,
      2         tl_no_id,
      3         count(*)
      4    from xxc_tr_num a,
      5         xxc_od_tab b,
      6         xxc_oth_tab c
      7   where a.tl_number = b.tl_number(+)
      8     and b.tl_id = c.tl_id(+)
      9   group
     10      by tr_no
     11       , tl_no_id;
    
         TR_NO   TL_NO_ID   COUNT(*)
    ---------- ---------- ----------
           100        333          1
           100        222          1
    

    See what returns the count? You have grouped according to TR_NO and TL_NO_ID. You must take into consideration the TL_NO_ID just put COUNT (TR_NO) does not increase the NUMBER of the whole group. To get the NUMBER on the whole group, I used the analytical function and did. Like this, see the number of the analytical function here

    SQL> select tr_no,
      2         tl_no_id,
      3         count(*),
      4         count(*) over(partition by tr_no)
      5    from xxc_tr_num a,
      6         xxc_od_tab b,
      7         xxc_oth_tab c
      8   where a.tl_number = b.tl_number(+)
      9     and b.tl_id = c.tl_id(+)
     10   group
     11      by tr_no
     12       , tl_no_id;
    
         TR_NO   TL_NO_ID   COUNT(*) COUNT(*)OVER(PARTITIONBYTR_NO)
    ---------- ---------- ---------- ------------------------------
           100        222          1                              2
           100        333          1                              2
    

    So to answer your question, yes you can't do in the HAVING clause...

  • How to export a video with two audio tracks such as: English and a steam engine, then open in vlc player, then select one of the two tracks?

    How to export a video with two audio tracks such as: English and a steam engine, then open in vlc player, then select one of the two tracks?

    Everything you always wanted to know about the acoustics in first Pro CC - YouTube

  • I try to run CC in a new computer products (the third argument: one of the two former stole) but I can't

    I try to run CC in a new computer product (the third argument: flew one of the two former) but I can not: when it asks me to try again or close the session on the other, I click on "continue", but nothing happens. What can I do? Thanks for any help on this matter.

    When you are prompted to sign out of your other two computers, do.

  • Trouble with the pdf form trying to "choose" one of the two paragraphs of text

    I am creating a PDF form and trying to find a way to choose one of the two groups of text that are approximately long paragraph. and having only the one I choose are visible on my pdf.  I tried to use a drop-down list, but it wouldn't accmodate the amount of text that I needed

    How to refer to a checkbox.

    I've added a new field of text (multiline) and put the java script in the section actions, just as you typed.  When I run the shape there is no box to choose and is not my default text (the text box is empty).  When I click outside the text box and then comes my 2 paragraph.

    All of the suggestions.

    BD

  • Sum of the two columns

    Hello.

    I use jdev 11.1.5

    = > I had created a Vo in the adf with the table named GrlJrl
    I need the sum of the two columns

    My scenario

    Da Ca
    500 100
    600 100
    100 200
    S 400 1200 (adding two field must be displayed in the user interface).

    someone help me reach this goal

    chk this
    Calculate the sum involved new VO

  • calculate the sum of the two columns - display the result in the third column

    Hello

    I have a report and I want to calculate the sum of the two columns of the report and display the total in the third column.

    For example: Sample_My_Report

    Col1 Col2 (Col1 and Col2) Total

    3-7-10


    can someone help me with this question.

    Thank you.

    Hello:

    If your report is an IR you can use the menu "Tool" to add columns calculated at the State

    CITY

  • Value of aggrigate of procedure - Get Oracle on the comparison of two-column based

    Hi all
    I've written a procedure that accepts an input parameter and returns a refcursor.
    The logic used in the procedure is:
    The procedure is used to display the summary and the report in detail. When the input parameter has more than one saperated comma then it will act as a synthesis report, and when there is just a value as input, then it will act like a detailed report.
    The input parameter is as "AA12345, BB45434, HJ89736," the first two characters is Brand_id and the rest of the 5 character is the propery_id.
    The aggrigation of aggrigation query is:
    Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
    Brand_id = 'AA' and SIte_id = '12345' Month_name group, year;
    The above query will worke fine for detail report when there is just a value for the entry as 'AA12345 '.

    The problem is coming to the summary report when I need to get the value of aggrigated for all the brand and the site which is entered in the input parameter.
    So I changed the query in the form:
    Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
    Brand_id | SIte_id in ('AA12345', 'BB45434', 'HJ89736') of the Group of Month_name, year;
    (I use parser function to parse a comma saperated values.)

    By doing this, I get the desired result, but the performance has decrised that the Index is based on Brand_id and Site_id but I'm using Brand_ID | Site_id for my research.

    The one you suggest another way to rewrite this query so that it can take the index and not give me the output of sesired.

    Database used: Oracle 10 g

    Thanks in advance.
    Sumit Narayan

    Published by: Sumit Narayan, 11 April 2010 22:00

    I'd be inclined to do something like that to analyze the list separated by commas, that allows you to join without the concatenation of the columns as you do now.

    ME_XE?select
      substr(column_value, 1, 2)            as brand_id,
      substr(column_value, 3, length(column_value))   as site_id
    from table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736'));
      2    3    4
    BRAND_ID   SITE_ID
    ---------- ----------
    AA         12345
    BB         45434
    HJ         89736
    
    3 rows selected.
    
    Elapsed: 00:00:00.20
    ME_XE?
    
    ME_XE?select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE  10.2.0.1.0  Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    5 rows selected.
    
    Elapsed: 00:00:00.39
    ME_XE?
    

    So for your case...

    Select
      f.Month_name,
      f.Year,
      sum(f.REVPAR),
      Sum(f.ADR)
    from FIS_KPI_TREND f, table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736')) t
    where f.Brand_id = t.brand_id
    and   f.SIte_id  = t.site_id
    group by f.Month_name, f.Year;
    

    Published by: Tubby 11 April 2010 22:12

Maybe you are looking for

  • Satellite A300D-151 not starting not don't logo, BIOS

    Hello I recently had problems with my A300D. During normal use, the screen has behaved weird, became white and normal several times until it stopped working. When I rebooted the green light, the DVD is available and I can detect two low beeps. That's

  • Unknown blue screen - UNEXPECTED_KERNEL_MODE_TRAP_M (1000007f)

    My computer from Dell gx270s keeps giving me a blue screen unknown. I used the debut of windows to obtain information about the error. Its as follows. Can someone tell me what means this error? Thank you Debug version of Microsoft Windows (R) 6.11.00

  • How you access via a text easier?

    Typing your text and you want to go back a few words, it is difficult to push around the word to get the cursor flashes next to the word or letter your trying to fix, at - it someone know an easier way to get to the word or letters that you try to ad

  • Need to import contacts and messages saved from a Windows Mail email account to another

    Recently changed ISPS but currently have two active accounts.  I would like to import/transfer saved messages and folders, and all contacts from the old account to the new account before the cancellation of the old account.  Both are configured throu

  • Cannot delete the 2 files

    I have 2 sitting files that I can't get rid of. Both are without extension and 0 bytes. Already watched by multiple threads and nothing seems to work to get rid of them.