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

Tags: Database

Similar Questions

  • How to use the TRUNC function with dates in the expression builder in OBIEE.

    Hello
    How to use the TRUNC function with dates in the expression builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.


    Thanks in advance

    Use it instead:
    TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE)

  • Using the model Params with links

    Hi all, I was wondering how I could use a model parameters to change the prefix for all links. For example, all the pages on my site uses relative paths to pages within the site. Some pages of the site are secure and get so directed to a "secure server" If the URL is different. These pages may not use the relative URL back to the 'normal', unsecured, site so that they use the full path "" http://www.whatever.com/ ' to links. " I think I can do two model params as follows:

    "" <!-TemplateParam name = "rootSite" type = "text" value = " http://www.whatever.com ' ->
    <!-TemplateParam name = "pageSecure" type = "boolean" value = "true"->

    but I need a way to browse the document for all of the links and set the "rootSite" inserted before what is already there. Is this possible? If so, how?

    Thanks in advance!

    Buddy

    I would do this-


    >
    >
    > but I need some how to search the document for all the links and
    > set
    > the 'rootSite' inserted before what is already there. Is this possible? If
    > Yes,.
    > How?
    >
    > Thanks in advance!
    >
    > Buddy
    >

  • Helps the model clause. Date field in the Dimension

    Hello, all.

    I'm having a problem with the clause type in my query. In my view, it may be a misunderstanding on my part, but I can't find any documentation that is opposed to the use of the date fields in the dimensions of my model.

    Given these data;
    LOGDATE               SHIFTNAME  BUILDING  UNIT  DOORNUMBER  INOUT    EVENTCOUNT
    2012-02-01 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-01 06:00:00      A        1800      R      Door 4     In          15
    2012-02-01 18:00:00      D        1800      R      Door 4     Out         17
    2012-02-01 18:00:00      D        1800      R      Door 4     In          19
    2012-02-02 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-02 06:00:00      A        1800      R      Door 4     In          14
    ...
    I write my SQL like this:
    SELECT logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
          RULES ()
    And I get the expected result. (The same table as above) But when I try to add rows using rules, I get no new line until the LOGDATE field is a date. For example, by using this code, I expect to get a new line, with a 100 EVENTCOUNT (and other fields as written) but I stiill get the same set of data (no line is added)
    SELECT logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
           RULES (eventcount[SYSDATE,'X','1800','R',4,'In'=100)
    However, when I turn the LOGDATE field in a CHAR data type (and make the SYSDATE a TANK in the same way) with the code below, all of a sudden I get the line I was expecting!
    SELECT TO_CHAR(logdate,'YYYY-MM-DD HH24:MI:SS') logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
           RULES (eventcount[TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'),'X','1800','R',4,'In'=100)
    
    
    LOGDATE               SHIFTNAME  BUILDING  UNIT  DOORNUMBER  INOUT    EVENTCOUNT
    2012-02-01 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-01 06:00:00      A        1800      R      Door 4     In          15
    2012-02-01 18:00:00      D        1800      R      Door 4     Out         17
    2012-02-01 18:00:00      D        1800      R      Door 4     In          19
    2012-02-02 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-02 06:00:00      A        1800      R      Door 4     In          14
    ...
    2012-02-07 15:18:33      X        1800      R      Door 4     In          100
    Can someone explain this behavior? I intend to do some calculations on the LOGDATE dimension and I would like to keep it as a date. Thanks in advance for any help!

    I do not get the same result. When I use SYSDATE, I don't get the extra line. When I use TO_CHAR (SYDATE...) as you say, I still don't get the extra line.

    However, when I use a constant date, such as TO_DATE (' 2012/02/07 02:00 ',' YYYY-MM-DD HH24:MI:SS'), then I get the extra line.

    This behavior is described in http://docs.oracle.com/cd/E11882_01/server.112/e25554/sqlmodel.htm#BEIGGGFJ

    «Using UPSERT creates a new cell corresponding to that referenced on the left-hand side of the rule when the cell is absent, and the cell reference contains only positional references * qualified constants *.»

    Best regards, stew Ashton

    P.S. "Oracle Database 11g Enterprise Edition Release 11.2.0.2.0.

    Published by: stew Ashton on 7 February 2012 23:03

  • Use the model of multiple data in one report

    You can have several data model and integrated into one report?
    How can I do? Have some examples of how to implement this.

    Yes

    http://download.Oracle.com/docs/CD/E12844_01/doc/BIP.1013/e12187/T518230T518233.htm#4510518

    try to create a report with the two queries.

  • When I use the mail merge with excel file, after I press ok the progress bar indicates "NaN", mail project window crashes. My record is nice little CVS n

    When I use the mail merge with excel file, after I press ok of the progress bar indicates "NaN", mail project window crashes. My file is in the correct format and small size (4-column 4 raws). I use an English version of thunderbird after accidentally, I installed one in my tongue.

    I am attaching the screenshot

    I solved the problem
    has been st@pid excel

    I created a CSV file in openoffice calculator and everything went smoothly

  • Create a target table by using the model of the ODI

    Hi all

    I am new to ODI. I'm try export table RDBMS for source RDBMS table at target.

    If we create the structure of the target in the trg schema table or we can create using the model fit obi by selecting new data store.

    Owb loading target tables is created and the data will be loaded.

    Pls help me about this.

    Thanks in advance.

    Hello
    You can create it in the two ways.if you create using ODI data store, you must select Create table option target in flow during loading of the target.

  • The charge would be created with the unique package with date id

    Hi all

    Thanks in advance,

    IAM new to ODI, in my process I dnt know below two constaraints how to do, please help me in this regard...

    1. the load would be created with the id of a single lot with the date and
    stamp under the unique number (when the load data from source to target).
    2. HIGHLAND field would have the line number incremented from
    .001 when records are inserted in the table

    30021986 wrote:
    Hello

    Thanks for the reply, my requirement is,
    1.i have field JELN in the target table, in that line number is incremented from de.001 in the table. (Field JELN would have the incremented number line from de.001 when the rows are inserted in the table)

    -> for what I had done using sequenceing odi_sequence craeating, but it will give higher error.
    and the second condition is

    Never use ODI sequence unless you do business with a technology that has no native sequence is
    (eg files). Most of the RDBMS has their own sequence, and you use these alone.
    For oracle, you must use . NEXTVAL in the field mapping. Be sure to run on the target.

    2. when iam loading the data from the source to target a unique batch number must be generated with the date and time stamp (the load would be created with the unique package with date id and + *)
    timestamp in the unique number +) *.

    You can use SYSTIMESTAMP in this area and do not forget to run on the target.

  • T-Shirt Designing (1): how to make wider white box (using the model of t-shirt)?

    CS6 using

    T-Shirt Designing (1): how to make the white box more wide inside the shirt (using the model of t-shirt)?

    Well, I learned that I can go to file > new from the template > blank template > T-shirt to start to create a design for my t-shirt.

    It shows a small picture of the t-shirt with a rectangle in the middle that also represents the large rectangle (where I create my design).

    Question, am I suppose to create the right design in the large rectangle?

    2nd... I figured out how to adjust the length and width of the largest rectangle (through the corners, then clicking on it to open the section length/width at the top of the screen). However, when I adjust the height and width, is not the same for the rectangle inside the shirt.

    What I'm trying to do, is ensure that my design takes more than forward of the sweater by expanding the width.

    How to make the small rectangle in the large t-shirt too?

    Hello

    The small rectangle in the t-shirt line drawing is a guide. So, what you need to do is unlock guides, remove the small rectangle and create a new.

    (1) go to the view > Guides > release Guides. You will now be able to edit the guides, which are light blue in my document.

    (2) just so that you know what I'm talking specifically, open the Layers panel and place you on the Guides layer. Click the arrow next to reveal the guides within the layer. I locked all the other layers in the document to make it easy for me.

    (3) select the small rectangle, and delete.

    (4) use the Rectangle tool to draw a new in size.

    5) option click on the new rectangle to open a launcher. Select make Guides.

    You now have a guide again, larger rectangle! Let me know if you have any other questions.

  • How can I fill the records using the value LOV

    Create a form based on the use of the following output Table EMP

    Create a database block IE control-> Dept No. block


    Create a database block - EMP
    Create a LOV to the Dept not according to the dept table.
    For the current No. Dept. Complete records of the employees

    How can I fill the records using the value LOV?


    Thank you

    Hello

    Create trigger KEY-LISTVAL for control_block.dept_no with code similar to the following:

    IF SHOW_LOV ('LOV_NAME') THEN
            SET_BLOCK_PROPERTY ('EMP_BLOCK', DEFAULT_WHERE, 'DEPT_NO = ' || :CONTROL_BLOCK.DEPT_NO);
         GO_BLOCK ('EMP_BLOCK');
         EXECUTE_QUERY;
    END IF;
    

    Hope this helps

    Best regards

    Arif Khadas

  • How to use the ESD document with structured templates

    Hello

    I started to learn working with SEDD. I have an existing ESD, now I'm suppose to use it to create documents. I created a new book and imported this ESD file to it. I can see all the items in the catalog of the element. But when I start to add items to the book and add a new document, the elements are turning to red. Referring to the User Guide, it is said EDD cannot be used directly and must be used with structured patterns. But I do not have these models structured with me. Can someone please tell me how to create these structured templates and how to use the ESD file with these models, and out of this problem.

    Thanks in advance.

    Although ESD exist in the form of a separate document, the only way that it can be used is when it is part of the model. As a model of structured FrameMaker, a structured model contains master pages, pages reference, character formats, paragraph formats, etc. IN ADDITION, a structured model contains a DSP. To add the EDD to your template file, or any document FrameMaker who will use it, open the template file and the file of ESD. Click anywhere in the template file, and then select file > import > element definitions. In the dialog box, select the EDD file as source and click Import. Then save the template file.

    To use the template file, open it and save it as a FrameMaker document, giving it the name you want. You can now create your structure.

    If you use a book, all documents in the book must use the same ESD. Open the template file. In the book file, select all the documents in the book. Then select file > import > element definitions. In the dialog box, select the template file and click Import. Once completed, all documents in the book have the same ESD. In addition, ESD is copied into the file of the book itself.

    You say:

    But when I start to add items to the book and add a new document, the elements are turning to red.

    It is is not clear to me what you do. While it is true that SOME elements of a book are in the book file, you cannot add a book of items in the folder (at least not as far as I know). In general, the book file, it encapsulates elements around the documents root elements in the book. You may need to update the book to get a part of the Red disappear lines. You may need to rearrange items in the structure of the book to remove the red lines.

    Hope this helps,

    Van

  • Why and how 'create a profile using the e-mail icon?

    When I try to send a screenshot of a web page, and after that I'm going to "email recipient" a small screen appears and tells me that "no profiles have been created.  To create a profile use the mail Control Panel icon.  What this means and how can I do?  I use outlook express and can not send another email, just not screenshots of web pages.  UPS used to before.  I recently "upgraded" in IE8.  Thank you!

    Check in Internet Options as your default mail Outlook Express Manager
    (The mail applet is to use with Outlook, part of the Office family and completely different from Outlook Express)

  • How to create IT strategy using the BES administrator API

    Hi all

    Can tell me, how to create IT strategy using the BES administrator API.

    Please provide me with the code example.

    Thanks in advance.

    Kind regards

    Sampath

    Hi Sebastian,.

    The Administration of BlackBerry API does not support the creation of it political. This feature is currently with the development of control and review for a future version of the BlackBerry Web Services for the Administration of the company.

    Kind regards

  • to use the NOW() function with operator (such as NOW () - 120) 11.1.1.6.11 or 11.1.1.7.1

    Hi all

    I want to use the function NOW with a different operator in obiee11.1.1.6.11 or 11.1.1.7.1

    but every time I have a creating a filter as

    TRAN_DATE is equal to NOW()-120, we become "an arithmetic operation is being performed on a non-digital type.»

    11.1.16.11 and 11.1.1.7.1

    Hare TRAN_DATE is in RPD datetime data type

    Can someone tell me how to replace the error and make the report run and return the results

    Do now () - 120 is a very simplistic way to look at it because it is highly ambiguous. IE: NOW less 120 "what?" Minutes? Seconds? Years? Petroleum products?

    Accuracy is the key. Now() gives a timestamp (a real timestamp DATA TYPE object!), so I guess you mean days.

    Timestamp data types are changed (projected through time) using the TIMESTAMPADD function, which in your case would by this formula:

    TIMESTAMPADD (SQL_TSI_DAY,-120, NOW()))

  • Anyone use the &lt; cfdocument &gt; tag with a &lt; cfloop &gt;

    Anyone use the < cfdocument > tag with a < cfloop >

    I'm generating more documents like this.

    < cfloop query = "myquery" >

    < cfdocument type = pdf >

    < html >... .HTML code here... < html >

    < / cfdocument >

    < / cfloop >

    But only the first document is generated in the browser?



    My requirement that I want to create multiple PDF and publish to folder and zip folder so that the user can able to download the ZIP file


    Thanks in advance

    My requirement that I want to create multiple PDF and publish to folder and zip folder so that the user can able to download the ZIP file

    (1) create a folder named, say, docsDir, in the current directory.

    (2) create PDF files, using suggestion of Eddie Lotter, name each file dynamically and store them in the folder docsDir.

    Insert here the code to generate the content of #filename # .

    (3) zip file, docsDir, store the resulting file, docsDir.zip, in the current directory.

Maybe you are looking for