need help to extract data based on the date

i want to  write the query for the below statements ?

1) net_bank_cr from rm_memorandum for the previous year end 31st March

2) net_bank_cr from rm_memorandum for the as on date

3) net_bank_cr from rm_memorandum as one year prior to current reporting date

The table structure of rm_memorandum is as given below:

create table RM_MEMO
(
AS_ON_DT DATE,
PAID_CAPITAL NUMBER(20,2),
TOTAL_OBE NUMBER(20,2),
CR_EQI_OBE NUMBER(20,2),
NET_BANK_CR NUMBER(20,2),
ADJ_NET_BANK_CR NUMBER(20,2),
DEP_CURREMT_CRR NUMBER(20,2),
LIAB_OTH_CRR NUMBER(20,2),
TOTAL_CRR NUMBER(20,2)
) 

is can be as...

/* Formatted on 2011/10/12 14:38 (Formatter Plus v4.8.8) */
WITH t AS
     (SELECT TO_DATE ('31/12/2010', 'dd/mm/yyyy') as_on_dt, 205 net_bank_cr
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('15/03/2011', 'dd/mm/yyyy'), 205
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('15/03/2011', 'dd/mm/yyyy'), 666
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('31/03/2011', 'dd/mm/yyyy'), 9856
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('31/03/2011', 'dd/mm/yyyy'), 521
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('05/04/2011', 'dd/mm/yyyy'), 20
        FROM DUAL
      UNION ALL
      SELECT TO_DATE ('07/05/2011', 'dd/mm/yyyy'), 965
        FROM DUAL)
--
SELECT *
  FROM t
 WHERE t.as_on_dt
          BETWEEN CASE
          WHEN (SYSDATE > ADD_MONTHS (TRUNC (t.as_on_dt, 'YYYY'), 3) - 1)
             THEN ADD_MONTHS (TRUNC (ADD_MONTHS (SYSDATE, -12), 'YYYY'), 3)
                  - 1
          WHEN (SYSDATE <= ADD_MONTHS (TRUNC (t.as_on_dt, 'YYYY'), 3) - 1)
             THEN ADD_MONTHS (TRUNC (ADD_MONTHS (SYSDATE, -24), 'YYYY'), 3)
                  - 1
       END
              AND CASE
          WHEN (SYSDATE > ADD_MONTHS (TRUNC (t.as_on_dt, 'YYYY'), 3) - 1)
             THEN ADD_MONTHS (TRUNC (SYSDATE, 'YYYY'), 3) - 1
          WHEN (SYSDATE <= ADD_MONTHS (TRUNC (t.as_on_dt, 'YYYY'), 3) - 1)
             THEN ADD_MONTHS (TRUNC (ADD_MONTHS (SYSDATE, -12), 'YYYY'), 3)
                  - 1
       END
/

Kind regards
friend

Tags: Database

Similar Questions

  • Help to extract data Clob to a column in a table that has several lines in a table

    Help to extract data Clob to a column in a table that has several lines in a table

    It works for only the first line

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    beef in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2);

    DECLARE

    buf CLOB.

    BEGIN

    SELECT H15_DOC

    IN buf

    OF H15TEST. H15_STAGE

    where rownum = 1;

    dbms_xslprocessor.clob2file (buf, 'XMLDIR', 'testfile2.txt');

    END;

    /

    -This error code

    CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';

    Grant read, write on DIRECTORY XMLDIR to the public;

    () dbms_xslprocessor.clob2file

    XData in CLOB,

    XMLDIR IN VARCHAR2,

    "testfile2.txt" IN VARCHAR2,

    CSID in NUMBER: = 0);

    DECLARE

    CURSOR xmlmycur IS SELECT H15_DOC

    OF H15TEST. H15_STAGE

    where rownum = 102140;

    l_clob CLOB.

    XData CLOB.

    BEGIN

    DBMS_LOB.CREATETEMPORARY (l_clob, true);

    DBMS_LOB.CREATETEMPORARY (xdata, true);

    OPEN xmlmycur.

    LOOP

    SEEK xmlmycur INTO xdata;

    dbms_xslprocessor.clob2file (xdata, 'XMLDIR', 'testfile2.txt');

    EXIT WHEN xmlmycur % notfound;

    END LOOP;

    CLOSE Xmlmycur;

    END;

    /

    ORA-21560: 3 argument is null, invalid or out of range

    ORA-06512: at "SYS." DBMS_LOB", line 991

    ORA-06512: at "XDB". DBMS_XSLPROCESSOR', line 324

    ORA-06512: at line 15 level

    FYI, it seems that the file being created will exceed 5 gig

    Yes, it is a known issue with DBMS_XSLPROCESSOR.clob2file with big files.

    Here is a slightly modified version of the code that I posted earlier, fixing WRITE_ERROR except:

    DECLARE

    v_file utl_file.file_type;

    -write a unique to clob

    procedure write_clob (p_content in clob) is

    v_buffer varchar2 (32767).

    V_POSITION pls_integer: = 1;

    v_amount pls_integer: = 32767;

    Start

    loop

    Start

    DBMS_LOB. Read (p_content, v_amount, v_position, v_buffer);

    exception

    When no_data_found then exit;

    end;

    UTL_FILE.put_raw (v_file, utl_raw.cast_to_raw (v_buffer), true);

    V_POSITION: = v_position + v_amount;

    end loop;

    end;

    BEGIN

    -Open the file

    v_file: = utl_file.fopen ('TEST_DIR', 'testfile2.txt', 'wb', 32767);

    -loops through the lines

    for r in)

    Select h15_doc

    of h15test.h15_stage

    )

    loop

    write_clob (r.h15_doc);

    end loop;

    UTL_FILE.fclose (v_file);

    END;

    /

  • Need help to open two images with the same file with different exposures on the screen at the same time in the Photoshop creative cloud (in previous versions we could open two images of the same nef (raw) file and then combine them on the screen with the

    Need help to open two images with the same file with different exposures on the screen at the same time in the Photoshop creative cloud (in previous versions we could open two images of the same nef (raw) file and then combine them on the screen with the move tool. They have become a composite of two layers which could be developed further with the mask tool.

    Hello

    Please go to the preferences > workspace and uncheck the option 'open the document in the tabs '.

    Now you can click on file and choose file > open and open the two images in two different windows which can be arranged side by side.

    Thank you

  • I need help to unite 2 users on the same CC account, can someone help me?

    I need help to unite 2 users on the same CC account, can someone help me?

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific time) <==> NOTE DAYS AND TIME

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • I need help about illustrator. I have the portable version of CS6, install and won't let me open the program. I get the error: 1 I have windows 7

    I need help about illustrator. I have the portable version of CS6, install and won't let me open the program. I get the error: 1 I have windows 7

    Error code 1 is often associated with permission issues. Have you tried to install Illustrator in a new user account with admin rights? If you want to download CS6, here's how to get it through creative cloud: html http://helpx.adobe.com/creative-cloud/kb/download-previous-versions-creative-applications.

    Let us know how it goes.

    Concerning

    Stéphane

  • All my photos are displayed such as BW because somehow I saved a preset to quickly develop and it records in BW.  This is for all of my photos.  Individually, I can cancel their but did need help how to get rid of the pre-selection, so he's going to defau

    All my photos are displayed such as BW because somehow I saved a preset to quickly develop and it records in BW.  This is for all of my photos.  Individually, I can cancel their but need help how to get rid of the preset then all photos of goes to Default or in the shot. Thank you

    Go to the develop module and highlight all the images in the film at the bottom of the screen. Enable automatic synchronization, and then click the reset button. To reset all the images in your camera default settings.

  • Need help to extract the data into a string of separate brackets

    Hello

    I have a scenario where I have to extract data into a string that is enclosed in [].

    Here's what I want to do...

    entry:

    [name_first] [name_mi] [name_last]

    required output: this must return all data that are placed between square brackets.
    name_first
    name_mi
    name_last

    I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.

    Thanks in advance.

    Hello

    You can use SUBSTR and INSTR
    This should work in Oracle 9:

    WITH     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    )
    ,     got_pos          AS
    (
         SELECT     x.txt
         ,     c.n
         ,     INSTR (x.txt, '[', 1, c.n)     AS l_pos
         ,     INSTR (x.txt, ']', 1, c.n)     AS r_pos
         FROM           table_x  x
         CROSS JOIN    cntr     c
    )
    SELECT        txt
    ,        n
    ,        SUBSTR ( txt
                   , l_pos + 1
                , r_pos - (l_pos + 1)
                   )     AS sub_txt
    FROM        got_pos
    ORDER BY   txt
    ,             n
    ;
    

    Sorry, I don't have an Oracle 9 database now; I had to test this in Oracle 10.

    jimmy437 wrote:
    ... I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.

    It's true. Regular expressions are very useful, but they are not available in Oracle 9 (or earlier).
    Oracle 9 has a package supplied by Oracle, OWA_PATTERN, which provides regular expression features:
    http://docs.Oracle.com/CD/B12037_01/AppDev.101/b10802/w_patt.htm
    I know it's the Oracle 10, documentation, but there are in Oracle 9, too.

    Oracle 9 is very old. You should consider the upgrade.

  • need help on filling data dynamically from list of choice while the page is loading

    Hi all

    I need to dynamically fill data in the picklist (drop-down list on the component) during the loading of the page itself, can you please a little help on this. I mean for the values of the component < f: selectItems > < af:selectOneChoice > must be filled dynamically, so that loading page. I will be grateful if you can provide examples of code.


    Thanks in advance



    Concerning
    Ashok E

    Hello

    the problem with your code is that it is not af:selectItem but f: selectItems


    *

    Frank

  • Need help to extract a CAB Secure Digital file in the Windows XP computer.

    Original title: can someone help me extract a CAB Secure Digital file.

    Hello administrators of Microsoft development network

    Please help me! check out a file .sdc.

    I want to download this file

    http://FTP.sh.cvut.cz/MSDNAA/Rapid_Setup/en_winxp_pro_with_sp2.SDC

    I use Windows XP Home Edition with Service Pack 2 x 86 OEM

    August 8, 2004

    Megabyte 556,7 ISO

    I have Net Framework 1.0 SP3 with and Net Framework 1.1 with Service Pack 1 and security update

    Net Framework 3.5 SP1 x 86 also from a drive of gray DVD containing all the files of the SDK software.

    Please be aware that I have the license key genuine for BONES in the download link :D

    I'm strugglin extract the .sdc by using an imagi.pl file

    the error I get, it's that his saying "not a valid .sdc format."

    Please make sure that the link of download Direct FTP to MSDN Academic alliance

    the last time that I extracted successfully a .sdc was Windows Server 2003 R2 Enterprise with SP1 x 86 retail

    but that was with my Windows Vista Home Premium with SP2 RTM (342266.iso) x 86

    ;' -(

    Help, please!

    Hello

    I recommend you to ask your question in the MSDN forum for assistance.

  • Need help setting bios to boot from the cd. I did already but the laptop does not start again for cd player.

    Hello

    I forgot that my administration windows log password after the holidays.  I have loaded down a free program called Ophcrack and had set my laptop to boot from cd 1 but I just cannot get the laptop to boot from a cd.  He just continued boot from the internal hard disk.

    The cd is an image and it is bootable on my desk.

    The model of laptop: laptop HP ENVY m6

    Product number: C2N77UA #ABL

    BIOS version: F.25

    Processor type: Intel Core i7-3632QM CPU @ 2.20 GHz

    OS: Windows 8.1

    I only did a password reset disk (I'm learning the hard way now!).

    I don't want to do a "System Recovery" because I have some data on it.

    I realize there are paid there password recovery tools windows, but I would like to use this 'free' program to try to break 1.

    I just need help / instructions to set the bios for laptop can be started from a cd.  I also tried to boot from a key USB but the laptop kept begin its internal drive.

    Help, please.  Thanks a ton!

    Ted

    Hi Ted,

    You are welcome

    Boot into the bios menu and go to the very section where you have disabled the Secure Boot.

    Find an entry called materials and this value to Activate.

    Save the changes and exit the bios.

    Follow the previous procedure below:

    Insert the bootable disc of Ophcrack and laptop stop.

    Tap away at the esc you key start Notepad to open the Start Menu.  Select boot options ( f9 ), use the arrow keys to select the CD/DVD drive and press ENTER.  You can also get a prompt to "Press any key to" continuous - it if requested.

    Kind regards

    DP - K

  • need help for calculation date

    I need help with this:

    I added successfully a document level script to add the date printed in my document

    this.getField("DatePrinted").value = util.printd ("mm/dd/yy", new Date());

    I now need to fill in a field named "Date" with a date that is 14 days after the date of DatePrinted.

    and I'm lost.

    Can anyone help?

    Get the current date/time

    var d = new Date();

    Add 14 days

    d.setDate (d.getDate () + 14);

    Set a field value

    getField("Deadline").value = util.printd ("mm/dd/yy", d);

    That last part may need to be changed depending on where you place the script. If it's the same script at the document level, the whole thing can be:

    Get the current date/time

    var d = new Date();

    Set a field value

    getField("DatePrinted").value = util.printd ("mm/dd/yy", d);

    Add 14 days

    d.setDate (d.getDate () + 14);

    Set another value of field

    getField("Deadline").value = util.printd ("mm/dd/yy", d);

  • Need help for reading in parallel on the same interface and writing XNET

    Hello. I need help to configure CAN interface to write and read from the same interface.

    I use NI PXI-8513/2. I use CAN1 as interface.

    My had TO send status messages CAN every 100ms. I have to read in order to return akntoowlege to keep DUT CAN interface happy and not make mistakes.

    So, I want to open Strim Session and readall frames in the loop. At the same time, I need to be able to write in a frame HAD at the time...

    I only need to read one picture at a time too, but since I know the ID, I can pull it from the stream.

    What I'm confusing all is how to put in place the same CAN1 interface to be able to write and read in parallel.

    I think I would get errors that interface is already in use.

    Since I'm new to CAN, I was read and write only when necessary. But, sometimes I was getting errors on my messages. Sometimes I get message, sometimes miss me. But, when I run CAN test criminal as sniffer he sends and written every time. I was told it's because it recognizes all messages.

    I opened to suggestions of how best to implement the interface.

    I guess I can use CAN2 and separator to work around this problem, but I would use an interface if possible.

    Thank you

    Hi Rus,

    The XNET hadrware takes care of most of the low level of detials for you. The reading and writing of the circuits are both connected to the bus at any time. When you write to the hardware it will try to put a frame on the bus at the first opportunity he can. If the frame loses arbitration material re - will attempt to send the frame up is successful. Reception equipment monitor activity on the bus, regardless of what it conveys. The material received will usually throw a framework that was sent by communication equipment, but there is an Echo property pass to circumvent this behavior too.

    Take a look at the example of the expedition: MAY-> NI - XNET-> Sessions-> multiple Sessions Intro-> CAN even exit entry framework Port unique Point.vi. Keep in mind that this example you will need to use a second CAN interface to recognize frames, it transmits. I would recoment against the example CAN output Frame Single Point which would mimic your ECU if you choose a type of cyclic frame running this example.

  • Need help with implementing DLL based on LabVIEW below call Lib

    Here is the list of C functions in the doc that I have, but I don't get the right result.

    I need help to understand how these features and how to configure it in LabVIEW

    Parameters

    voltType
    [in] Specifies a voltage detector to get the value of. There may be flags
    VCORE (1<>
    V25 (1<>
    V33 (1<>
    V50 (1<>
    V120 (1<>
    VSB (1<>
    VBAT (1<>
    VN50 (1<>
    VN120 (1<>
    ATV (1<>
    retval
    [out] Points to a variable in which this function returns the voltage in volts.
    Typesupport
    [out]
    If the value is specified as a (non-NULL) pointer to a variable, it will return the types of sensors available in indicators at the level of the ILO-ORed
    Return value
    TRUE (1) indicates a success; FALSE (0) indicates a failure.
    Remarks
    Call the function first with a typesupport non-NULL of the sensors available fan and a subsequent call to get the required voltage.

    Thanks to all...!

    I solved this problem.

    There was a problem in the configuration of the VoltType. We have a cluster of bits.

    Here is the screenshot.

  • Need help Kodak 5500 AiO printer over the network.

    I have a kodak 5500 AiO printer. I have vista on all my computers (1 bureau and 3 laptops). I downloaded the sp2 for vista on all computers, after I downloaded sp2 desktop mouse and keyboard froze, I had to uninstall sp2 to make it work. Now the printer on my home network to print or not be discovered by my laptop. I can see the printer on the network to my laptop but I can't connect to it. The printer is on the desktop via a usb cable. I deleted the printer drivers and reinstalled and downloaded the software and drivers for the latest printer.  I need help.

    Thank you

    Phil

    original title: using network printer

    Everyone,

    That's what I had to do to get my printer working once Vista it has messed up. You do the first two steps on the computer to which the printer is connected. The last step that you do for your laptop or you want to connect the printer to the main computer. I hope this helps.

    Hey all,.

    We had this same problem...

    We had to follow the procedure proposed by Drompa...

    > 1) share permissions
    >> 1. In explorer, select C:\windows\system32\spool\PRINTERS
    >> 2. Make a right click, properties
    >> 3. Tab sharing
    >> 4. Advanced sharing
    >> 5. Check "share this folder".
    >> 6. Permissions
    >> 7. Grant everyone full control
    >>
    (> NTFS permissions 2)
    >> 1. In explorer, select C:\windows\system32\spool\printers
    >> 2. Make a right click, properties
    >> 3. Security tab
    >> 4. Edit
    >> 5. Add
    >> 6. Advanced
    >> 7. Find now
    >> 8. Select 'NETWORK '.
    >> 9. Ok
    > 10. Total control of the NETWORK grant

    AND THEN we had to install local printers, using the port trick...

    1. go to 'printers '.
    2. click on "add a printer".
    3 Add a local printer.
    4. "create a new Port.
    5. use the "Local Port" option
    6. on "Enter a Port name" enter: "\\Computername\Printername".

    And if all goes well should do!

    Good luck!

    Credit to Drompa and otherdreams to help out me.

    Phil

  • Need help with custom script to rename the layers

    Hello world.

    I need help to write a custom script (because I suck at it) that will allow me to go through all the layers and sous-calques for a specific name ('X') and give it a new specific name ('Y').

    I have had success using the script below, but it does not work on any text layers names where the text layer was previously particularly well-known in 'X' and now changed needs.

    Any help is greatly appreciated.

    * Note: this script was originally used to find any layer with 'Copy' in its name and remove with anything after (to correct the problem of duplication of layers by adding this text).

    This is why the function is named removeCopy. It works for renaming layers also - just not a layer of text unfortunately.

    #target illustrator

    function removeCopy() {}
    If (app.documents.length == 0) return;
    var app.activeDocument = docRef;
    recurseLayers (docRef.layers);
    }
    removeCopy();
    function recurseLayers (objArray) {}
    for (var i = 0; i < objArray.length; i ++) {}
    ObjArr [i] .name = ObjArr [i].name.replace (/ \s*current name\s*\d*/, 'new name');
    If (objArray [i] .layers) recurseLayers (. layers.length > 0 ObjArr [i]);
    }
    }

    I finally found something after searching forums for a week. My confusion was related to the way Illustrator treats real layers against text/path/object "layers." Instead of layers, I had to use the pageItems in the script. The code below works. Thanks to Gustavo for his answer in another thread and Carlos I thank you for this looking too good! You're great to be ready to help models do more advanced things with Illustrator.

    var doc = app.activeDocument;
    var items = doc.pageItems;
    for (var g = 0; g)
        elements [g] .name = elements [g].name.replace ('Century Schoolbook text line', ' MonogramText: Century Schoolbook ");
    };
    App.Redraw ();

Maybe you are looking for

  • Equium L20-197 - Wi - Fi problems

    I is currently experiencing major problems with connecting to the internet with my computer satellite phone. I have a BT Home Hub and for the last two weeks both my desktop or my laptop have experienced difficulties. They were both showing as being c

  • ITunes supports the zune?

    I remember reading a few years ago that you can upload your playlists from iTunes to a Zune device.  True? Thanks for any help... Rick

  • Maybe a scam?

    I have a saying of telephone number 16617480240 Skype user who keeps calling my house saying they are Microsoft! They said that I paid you a 149.00 and will refund 200.00 dollars, but in order to hit the sign of Microsoft and the letter R. Is it a sc

  • Someone hacked into my hotmail, MSN mail.

    I have no idea who is using my old email, they speak to my friends and poster of the weird things about me, I'm really scared, because I haven't used that account since 2009 and now someone it is enabled and that someone uses it, I have no idea who h

  • BackgroundFactory draw gradients only left to right not up-down

    I want to draw a gradient backgrount from top to bottom. BackgroundFactory.createLinearGradientBackground( colorTopLeftDefault, colorTopRightDefault, colorBottomRightDefault, colorBottomLeftDefault); topLeft = Color.BLACK topRight = Color.BLACK botto