Add dummy record if condition fails

How can I add a dummy record when a condition fails.
with sample_data as 
( select 1 as week_nbr, 123.23 as sales, 200.00 as guests from dual union all 
  select 2 as week_nbr, 453.23 as sales, 300.20 as guests from dual union all 
  select 3 as week_nbr, 3123.23 as sales, 400.00 as guests from dual union all 
  select 4 as week_nbr, 123.25 as sales, 2300.13 as guests from dual 
) 
select * from sample_data
union all 
select 5 as week_nbr, 0 as sales, 0 as guests from dual 
where when sample_data contains no records with week_nbr = 5 

Hello

Lakmal Rajapakse wrote:
Hi Frank,.

I think that you need and the following clause for the not exists subquery:

where week_nbr = 5

Thank you! I missed that.

The method of outer join probably won't help in this case.

Tags: Database

Similar Questions

  • Create dummy records using the model cluase with date field condition

    Hi all

    I have two tables below:

    create the table Interest_date

    (

    date of interest_date_field,

    Number of Interest_amount

    );

    create the table sys_date

    (type varchar2 (30),)

    date_value date

    );

    Insert all

    IN Interest_date values (to_date('01-11-2012','DD-MM-YYYY'), 20)

    IN Interest_date values (to_date('01-12-2012','DD-MM-YYYY'), 40)

    IN Interest_date values (to_date('02-01-2013','DD-MM-YYYY'), 60)

    IN Interest_date values (to_date('01-06-2013','DD-MM-YYYY'), 80)

    IN Interest_date values (to_date('01-07-2014','DD-MM-YYYY'), 10)

    IN Interest_date values (to_date('25-11-2014','DD-MM-YYYY'), 20)

    INTO SYS_DATE VALUES ('FIRST_DATE',TO_DATE('01-06-1900','DD-MM-YYYY'))--note: the year is not important but the date is used for other

    INTO SYS_DATE VALUES ('FIRST_DATE',TO_DATE('01-12-1900','DD-MM-YYYY'))--note: the year is not important but the date is used for other

    Select * twice;

    Requirement:

    I need to write a select statement that retrieves all the records in interest_date and add a dummy record according to what follows:

    -in NO case of JJ - MM interest_date_field for a given year (year group) = DD - MM of the date_value in sys_date where the type is "FIRST date"-> add a dummy record (date_value for type FIRST_DATE yyyy = year of interest_date_field, - 1)

    -in NO case of JJ - MM interest_date_field for a given year (group by year) = DD - MM of the date_value in sys_date where the type is 'SECOND DAY'-> add a dummy record (date_value for type SEOND_DATE yyyy = year of interest_date_field, - 1)

    Desired output:

    Interest_date_field Interest_amount

    06/01/2012-1

    11/01/2012 20

    12/01/2012 40

    01/02/2013 60

    06/01/2013 80

    12/01/2013-1

    06/01/2014-1

    07/01/2014 10

    25/11/2014 20

    01/12/2014-1

    Thank you very much

    Ferro

    Why not combine the first with the second approach:

    with the years as)

    Select distinct

    TO_CHAR (interest_date_field, "YYYY") y

    of Interest_date

    )

    year_dates as)

    Select

    to_date(y||) MD, 'YYYYMMDD') d

    years

    (to_char(date_value,'MMDD') md by selecting in SYS_DATE)

    )

    Select

    I have interest_date

    an interest_amount

    of interest_date

    model

    dimension (interest_date_field i)

    measures (Interest_amount a)

    rules)

    a [for i (select year_dates d)] = nvl (a [cv ()],-1)

    )

    i order

  • How can I add a 'Record number' column in a folder that contains the music?

    How can I add a 'Record number' column for my music files?  It does not appear as a column I add when I right click on the folder in its display of details.  Zune program uses this file attribute.

    I learned from this thread (http://social.technet.microsoft.com/Forums/en/w7itpromedia/thread/47e46e5a-63c0-4a92-b39d-64ea9a07953e) Windows Media Player 12 IS NOT only an attribute of disc number!  Incredible.  Zune has it, and it works fine.   Come on Microsoft, please join us in THIS century it please?

  • Is it possible to avoid the "" Record 1: discarded - failed all the clauses WHEN. ' "

    When using when clause sqlldr. It generates too many lines as below-

    "Record 1: discarded - failed all WHEN clauses."

    "" Sheet 2: discarded - failed all WHEN clauses. ""

    "" Record 3: discarded - failed all WHEN clauses. ""

    ' Record 4: discarded - failed all WHEN clauses. »


    If she rejects millions of records. in the log file, it shows millions of lines. size of the log file is too big.

    He takes seriously the space on my hard drive.

    at the same time I need other details in the log-file

    125466 lines loaded successfully.

    0 rows not loaded due to data errors.

    65523 lines not loading because all WHEN clauses were failed.

    0 rows not populated because all fields are null.

    Run started on Fri Jan 23 12:27:16 2015

    Run finished Fri Jan 23 12:27:18 2015

    Time was: 00:00:01.70

    Time processor was: 00:00:01.16

    None of the parameters of SQLLDR to avoid these lines...?

    Oracle 11.2.0.1.0

    Windows 2008

    Although you can use SILENT = RELEASES in your SQL * Loader command line to remove the output to the screen, as much as I know there is no way to remove in your log file.  However, if you use an external table, you can use NOLOGFILE, but which eliminates the whole logfile, not only releases and requires that the data file is on the server, not the client.

  • If Condition get spent during execution, even when the data Condition fails

    Hi gurus,

    We came back to condition in the procedure below


    / * Condition in a procedure * /.

    If i.effective_end_date > p_end_date and i.effective_start_date < = p_end_date

    then

    Start

    If l_future_rec_flag then

    -Call API with update insertion mode

    l_datetrack_mode: = hr_api.g_update_change_insert;

    on the other

    -Call API with Update Mode

    l_datetrack_mode: = hr_api.g_update;

    end if;

    -api call

    end;

    end if;

    / * Condition in a procedure * /.

    data sent to this if condition during execution is as below, I printed it using fnd_file.put_line (fnd_file.log).

    i.effective_end_date > p_end_date and i.effective_start_date < = p_end_date

    31 December 12 > 31 March 13 and 1 January 13 < = 31 March 13

    , my doubt is that the above data made it clear the if condition fails with past data. but during the execution, the condition happened and will block to start and run the api and get api error.

    Error occurred during the assignment process. Check the log file for more details. ORA-20001: unable to change the update of insert mode when there is no future lines

    Cause: The insert DateTrack change update mode can be done if there is no future lines after the current date.

    Action: Perform an update operation DateTrack or erase your changes.

    Error occurred during the assignment process. Check the log file for more details. ORA-20001: unable to change the update of insert mode when there is no future lines

    Can anyone help on this.

    Thanks in advance

    Hi gurus,

    Now, it has been resolved, we used the to_date for date comparison function and now it works perfectly.

  • I created a pdf with blocks of text to fill out form. Is it possible to add a record button instead of having someone go to produce and record?

    I created a pdf with blocks of text to fill out form. Is it possible to add a record button instead of having someone go to produce and record?

    You can add a save button slot for your file, but not a button Save.

  • The default values on the retail block for dummy record gets inserted in detail blk

    Hi all

    I have a master block
    a block of detail and a detail for detail block block

    For every master I have or have no certain records in the block of retail

    for each master, I have a few detail records

    for each detail record I may or may not have the corresponding detail records

    Let's take an example
    I navigate a primary record to the detail record.
    in the 3rd block of retail, there is no record for the record in detail, but I have some default values.

    Now I navigate to the 3rd block of detail and I do not insert records and then exit the screen

    Here oracle asks me to save all the changes I made (I did no changes)
    and by clicking on Yes, there is a dummy record is created for a 3rd detail record

    Please help me

    Thank you

    This is the default values are to mark the block as being changed. That's why you get the message "do you want to save the changes.

    I suggest that you fill out elements of the base with the default values table and fill out the matching elements from the base on a prior insertion trigger table.

  • Can I add dummy columns in OBIEE10g?

    Hello

    I have a situation where I have to add three columns that are not available in the repository. Can I add in OBIEE 10g?

    Given that regulatory reports, it follows a specific structure, in which I have not the columns are not available in RPD., I need to show them the empty values throughout the report.

    Pls help me.

    Thank you
    Pavan

    Hi Pavan,

    Yes, you can add dummy columns which are not available in the .rpd. You add any column of the report and change its function to reflect that the static value as the fx could be "NA".

    I hope this helps.

    Thank you
    Diakité

  • Add new records to the table of the ADF

    Hello

    I use Jdev 11.1.1.3.0.
    I have a Page of the ADF with detail Table of form - master, I want to add new records to the table reflecting in DB. Is it possible to do? pointers or demo?


    Thank you
    MB

    What are the components are used in your table? When you created the table originally, you specified as a table read-only? If your table contains components of af: outputText, then you will need either manually change components entry way, or remove the table and re-drop-the-in the form of table (not read-only)

    John

  • Disable a checkbox in a report if a condition fails

    Hello

    I have a requirement to disable a checkbox in a report if a condition fails. For example, I'll have the report

    code as
    apex_item.checkbox(1,"EQUIPMENT_ID") Tick,
    EQUIPMENT_TYPE as "Device Type",
    EQUIPMENT_NAME as "Device Name",
     CUSTOMER_NAME as "Customer Name",
     SITE_NAME as "Site Name"
    
      from DEVICE_VIEW
    Here I'll take checkbox on each line. I want to disable the checkbox in a few lines in the loading of the page

    itself according to a value in the database. For example, if the status of the discovery of discovery table is '2', where

    the equipment_id is the same as the equipment_id in the report (checkbox value) I need to disable this check box. Please

    Help

    Thank you

    TJ

    Hello

    I have not tested this, but you can for example use CASES if you select this checkbox column?

    something like

    CASE WHEN status = 1 THEN
    apex_item.checkbox(1,"EQUIPMENT_ID")
    ELSE
    apex_item.checkbox(1,"EQUIPMENT_ID",'disabled')
    END tick,
    ....
    

    BR, Jari

  • How to add a record button on the front panel to save waveform data

    Hi, I'm new kind of LabVIEW and I worked on a code for an agilent oscilloscope communicate via GPIB and so far it works well on the collection of these two analog channels one by one, "Not UNLIMITED" but it does the trick (vpp, Vrms, frequency, etc.).  I've added the feature to add data to a .csv file waveform (problem: opens a dialog box until the user gathers all the data.) Solution: I want the user to save the. File CSV whenever he wants to use later on the front panel). I've added another feature to get a snapshot of the curve waveform (problem: opens a dialog box.) Solution: I want the user to save the JPEG file, whenever he wants to take a snapshot ("take snapshot" button on the front panel)).  I work with the agilent hp54645d driver. I have attached my code, if someone can tell me please how do I do this (maybe cabling and structures are solutions do not know). Thank you in advance.

    I would recommend adding a case structure just around the two record VI and a button to check the condition of the structure of each case. If you want a button to control both save functions you can put the two record functions in the same structure of business controlled by a single button. You are right in saying that the loop will cause your code runs until the stop button is pressed or until the stop condition is met. If you are wanting the while loop to stop once the recorded information you can use the button that you use to control structures case to also stop the while loop. I hope this information helps.

  • Making a record of recovery failed

    I was doing the recovery disks while the process has failed.

    The third disc of four, would not begin to validate, twice.  Then when he did it again, the utility gave an error that he had problems now.

    As with most windows problems, I rebooted.  My system is installing 47 updates of windows.  He seemed to know when I started but now add more.

    Question, is this mess up to my recovery disc creation?  If I do the last two discs, the first two will be compatible?

    It looks like not there is a way to restart the recovery disc creation process, or is it?

    Thanks for the help.

    Richard

    Hi RAPearson

    Question, is this mess up to my recovery disc creation?  If I do the last two discs, the first two will be compatible?

    No, it won't conflict as only the programs and windows operating system factory parameters is burned.

    It looks like not there is a way to restart the recovery disc creation process, or is it?

    Here, too, it's a no it'll start you. Use good quality DVDs.

    Hope this fixes the problem

    Thank you

  • Include collections from tabular masks to add new records.

    Hello!

    Masters, now that I'm here with a condition, have a collection, phones, which can be more phones to their respective characteristics, I wonder if you can put a mask my item in collection on the phone when I get select the database, place the mask when running to see, but also necessido put the mask over the entrance of new values would like to do this in tabular form, created with collections? I put a picture to try to clarify my doubts and to find out what type of solution could use, I do not know how?

    Thanks again.

    mascara.jpg

    Hello!

    I came here to say that I could do the formatting of the phone as needed, created a function Java to layout form, under this code which created and added to the HTML header, is perfect, and add the header also put the code on the creation of collection, just below, I explain how I made, I put the answer here to have doubts, to use, you can have better alternatives but this suited me perfectly, this can be changed for other needs.

    HEADER:

  • Cannot add the recorded soundtrack

    I have a samsung with android top note5. I tried every way possible to add my own recorded voice files or any other audio file to my clip but without success.

    I tried to put it in the directory of the music, but it won't add the music. I can use audio files that accompany the first clip. I see 'playlists', 'albums', 'artists' and 'songlists', but they are gray and impossible to enter.

    How can I add my own soundtrack?

    Try MP3 - works for me every time.

  • editing a table to add the number of columns fails with ORA-01792

    I'm editing a table to add columns, and ORA-01792 receiver: maximum number of columns in a table or view is 1000. The table of the altar will be no more than 1000 columns. The environment is RHE5 Oracle 11.2. ALTER statement adds a lot of columns in the table, but when I do a manual change to add a dummy column it works, after that, if I run the original the change works!

    What is a table compressed with unused columns?

    This may explain the error with the limit of 1000.

Maybe you are looking for