Very Important (Query to display the output in required format)

CREATE TABLE TEMP(X VARCHAR2(10),Y VARCHAR2(100));
INSERT INTO TEMP('RIDER1','2001-12;2002-32;2003-42');
INSERT INTO TEMP('RIDER2','2001-52;2003-72');
SELECT * FROM TEMP
Initial Out Put in 2 columns X/Y_
X Y
RIDER1 2001-12;2002-32;2003-42
RIDER2 2001-52;2003-72
Write a Query to display the above data in the format below in 3 columns A/B/C*
A B C
Rider1 2001 12
Rider1 2002 32
Rider1 2003 42
Rider2 2001 52
Rider2 2003 72

So your old version doesn't support Regular expression. It will be very easy and efficient if you could use regular expression.
SQL> SELECT x,TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 1)) col2,
  2           TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 2)) col3
  3   FROM (
  4     SELECT DISTINCT x,regexp_substr (y, '[^;]+', 1, level) col2 
  5     FROM temp 
  6     CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (y, '[^;]+'))  + 1
  7     ORDER BY 1,2
  8        );
X          COL2
COL3
RIDER1     2001
12
RIDER1     2002
32
RIDER1     2003
42
X          COL2
COL3
RIDER2     2001
52
RIDER2     2003
72But for your version you can use something like
SQL> /* By curtesy Frank Kulash */
SQL> SELECT x,SUBSTR(the_value,1,INSTR(the_value,'-',1)-1) col2,
  2           SUBSTR(the_value,INSTR(the_value,'-',1)+1)col3
  3  FROM (
  4        SELECT DISTINCT x,SUBSTR(y,
  5                            DECODE(level,
  6                                   1,
  7                                   1,
  8                                   INSTR(y, ';', 1, level - 1) + 1),
  9                            DECODE(INSTR(y, ';', 1, level),
10                                   0,
11                                   length(y),
12                                   instr(y, ';', 1, level) -
13                                   DECODE(level,
14                                          1,
15                                          0,
16                                          INSTR(y, ';', 1, level - 1)) - 1)) the_value
17                FROM temp
18              CONNECT BY level <=
19                         LENGTH(y) - LENGTH(REPLACE(y, ';')) + 1
20          )
21  ORDER BY 1,2,3                     
22       ;
X          COL2
COL3
RIDER1     2001
12
RIDER1     2002
32
RIDER1     2003
42
X          COL2
COL3
RIDER2     2001
52
RIDER2     2003
72
SQL>

Similar Messages

  • Problem is displaying the output in required format

    Hi,
    I have a structure defined in DDIC in which i have a field REMAIN -this fied is to show  Remaining numbers in a range, I have given the type of the field as NUMC and I get the value caluclated in a field W_REM which is of type C,now I pass this W_REM to the DDIC struture and use ALV to display on screen, it gets displayed as 004879 but i want it to be displayed as 4,879 ..tried to give DEC in DDIC but it didnot work..what to give....Please help..its urgent!
    Points will be awarded.
    Thanks,
    Deepti

    Hi,
    i think this logic may help u:-
    data V_val type p. or like curr
    V_val = W_REM.
    write V_val to <DDICstructurename> - REMAIN.
    write :  <DDICstructurename> - REMAIN.
    or
    at fieldcatalog
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-tabname = 'Net Price'.
    fieldcatalog-datatype = 'CURR'
    append fieldcatalog to fieldcatalog.
    regards,
    Mekala VIjay

  • Display Report output in Matrix format

    Hi
      I want to display normal report output in somewhat this manner.
    I will have one change requrest number and many transport requests will be assigned to that change request number, and to the transport requests many objects will be assigned.
    I have to display the output in this format:
    Change Request 1  |   Tr No.1 |  Tr No.2 |  Tr No.1 | and so on....
    Obj1
    Obj2
    Obj3
    Change Request 1  |   Tr No.1 |  Tr No.2 |  Tr No.1 | and so on....
    Obj1
    Obj2
    Obj3
    Like this it should go on.
    I have done the coding part, how to display the data in the above format i am not getting any idea, please help me out if you have any ideas.
    Thanks & Regards
    Haritha.

    Hi Vijay,
      First of all thank you for the response.
    I am retrieving the data from different tables and putting all the data in one internal table called i_final. Below is the declaration of that internal table and how i have populated the data to that. I am using control break statements to display the data but the data is coming in the next line.
    Please see the final internal table:
    1. Declaration:
    Data:Begin of i_final occurs 0,
           ccsnr like ysts-ccsnr,
           trkorr like ysts-trkorr,
           obj_name like e071-obj_name,
           check_box(1),
           status LIKE YSCS-STATUS,
          End of i_final.
    2. Populating different internal tables data to this table:
      loop at i_ccno.
        i_final-ccsnr = i_ccno-ccsnr.
        i_final-trkorr = i_ccno-trkorr.
        read table i_status with key trkorr = i_ccno-trkorr.
        if sy-subrc = 0.
          i_final-status = i_status-status.
        endif.
        read table i_obj_name with key trkorr = i_ccno-trkorr.
        if sy-subrc = 0.
          i_final-obj_name = i_obj_name-obj_name.
        endif.
        append i_final.
        clear i_final.
      endloop.
    3. Using Control break statements to display the data.
      sort i_final by ccsnr.
      loop at i_final.
         at new ccsnr.
           write:/2 i_final-ccsnr.
         endat.
           write:20 i_final-trkorr.
           uline.
      endloop.
    But the output is coming like this:
    CHG0003785  HSDK933109
                          HSDK933111
                          HSDK933113
                          HSDK933143
                          HSDK933268
    But i want the output like this:
    CHG0003785 | HSDK933109  |  HSDK933111  |   HSDK933113
    Thanks & Regards
    Haritha.

  • Is it Possible to display the output of the ALV list as POP-UP

    Hi Experts,
                     Is it Possible to display the output of the ALV list as POP-UP, if yes then provide some ideas on it.
    thanking in advance,
    Samad.

    Hi samad, it is possible to display alv list as pop-up by using the FM " REUSE_ALV_POPUP_TO_SELECT"
    try this sample code
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
          EXPORTING
       I_TITLE                       =  P1_TITLE
           I_SELECTION                   = 'X'
           I_ZEBRA                       = 'X'
      I_CHECKBOX_FIELDNAME          =
      I_LINEMARK_FIELDNAME          =
      I_SCROLL_TO_SEL_LINE          = 'X'
            I_TABNAME                     = 'T_VBAP'
           I_STRUCTURE_NAME              =  'T_VBAP'
           IT_FIELDCAT                   =  T_FCAT2
           I_CALLBACK_PROGRAM            = 'ZTEST_ALV_POPUP'
       IMPORTING
           ES_SELFIELD                   = I_SELFIELD
           E_EXIT                        = W_EXIT
          TABLES
            T_OUTTAB                      = T_VBAP.
    i think it will solve your problem
    Regards,
    Vijay

  • To display the output of a FM inside a tree

    Hi all,
    'REUSE_ALV_POPUP_TO_SELECT'  is a FM for displaying or selecting table entries in internal tables in a
    popup .
    I need to display the output if this FM inside a tree.
    That is when i expand the tree ,  the output of the FM shoul be displayed .
    Can you please suggest a demo program for this, or a way in which i can do it?
    Regards,
    Harshit Rungta

    No way You can choose any other ALV.
    Kanagaraja L

  • How to display the output screen when I use bdc.

    hey expert,
    I want to display the output screen when i use bdc without using mode 'A'.
    thank you.

    Hi,
    You can go for mode 'E'.. it will display the output screen directly and if there is any error in the transaction you would get that particular screen and you can correct and continue after which you will get the final screen if anything goes fine...
    check this sample code....
    I had a program if you execute below program it automatically creates a new zprogram.
    REPORT  zprogram_create_recording.
    PARAMETER:
      p_prog    TYPE sy-repid OBLIGATORY,
      p_shtxt TYPE repti OBLIGATORY,
      p_pack  TYPE devclass DEFAULT '$tmp'.
    DATA:
      t_bdcdata LIKE
       STANDARD TABLE
             OF bdcdata.
    DATA:
      wa_bdcdata LIKE LINE OF t_bdcdata.
    REFRESH t_bdcdata.
    CLEAR wa_bdcdata.
    wa_bdcdata-program    =  'SAPLWBABAP'.
    wa_bdcdata-dynpro     =  '0100'.
    wa_bdcdata-dynbegin   =  'X'.
    wa_bdcdata-fnam       =  'RS38M-PROGRAMM'.
    wa_bdcdata-fval       =  p_prog.
    APPEND wa_bdcdata TO t_bdcdata.
    CLEAR wa_bdcdata.
    wa_bdcdata-fnam       =  'BDC_OKCODE'.
    wa_bdcdata-fval       =  'NEW'.
    APPEND wa_bdcdata TO t_bdcdata.
    CLEAR wa_bdcdata.
    wa_bdcdata-program    =  'SAPLSEDTATTR'.
    wa_bdcdata-dynpro     =  '0200'.
    wa_bdcdata-dynbegin   =  'X'.
    wa_bdcdata-fnam       =  'RS38M-REPTI'.
    wa_bdcdata-fval       =  p_shtxt.
    APPEND wa_bdcdata TO t_bdcdata.
    CLEAR wa_bdcdata.
    wa_bdcdata-fnam       =  'TRDIR-SUBC'.
    wa_bdcdata-fval       =  '1'.
    APPEND wa_bdcdata TO t_bdcdata.
    CLEAR wa_bdcdata.
    wa_bdcdata-fnam       =  'BDC_OKCODE'.
    wa_bdcdata-fval       =  'CONT'.
    APPEND wa_bdcdata TO t_bdcdata.
    IF p_pack EQ '$TMP'.
    *local object
      CLEAR wa_bdcdata.
      wa_bdcdata-program    =  'SAPLSTRD'.
      wa_bdcdata-dynpro     =  '0100'.
      wa_bdcdata-dynbegin   =  'X'.
      wa_bdcdata-fnam       =  'KO007-L_DEVCLASS'.
      wa_bdcdata-fval       =  ' '.
      APPEND wa_bdcdata TO t_bdcdata.
      CLEAR wa_bdcdata.
      wa_bdcdata-fnam       =  'BDC_OKCODE'.
      wa_bdcdata-fval       =  'TEMP'.
      APPEND wa_bdcdata TO t_bdcdata.
    ELSE.
    *package assignment with request
      CLEAR wa_bdcdata.
      wa_bdcdata-program    =  'SAPLSTRD'.
      wa_bdcdata-dynpro     =  '0100'.
      wa_bdcdata-dynbegin   =  'X'.
      wa_bdcdata-fnam       =  'KO007-L_DEVCLASS'.
      wa_bdcdata-fval       =  p_pack.
      APPEND wa_bdcdata TO t_bdcdata.
      CLEAR wa_bdcdata.
      wa_bdcdata-fnam       =  'BDC_OKCODE'.
      wa_bdcdata-fval       =  'ADD'.
      APPEND wa_bdcdata TO t_bdcdata.
      CLEAR wa_bdcdata.
      wa_bdcdata-program    =  'SAPLSTRD'.
      wa_bdcdata-dynpro     =  '0300'.
      wa_bdcdata-dynbegin   =  'X'.
      wa_bdcdata-fnam       =  'KO008-TRKORR'.
      wa_bdcdata-fval       =  ' '.
      APPEND wa_bdcdata TO t_bdcdata.
      CLEAR wa_bdcdata.
      wa_bdcdata-fnam       =  'KO008-AS4TEXT'.
      wa_bdcdata-fval       =  ' '.
      APPEND wa_bdcdata TO t_bdcdata.
      CLEAR wa_bdcdata.
      wa_bdcdata-fnam       =  'BDC_OKCODE'.
      wa_bdcdata-fval       =  'LOCK'.
      APPEND wa_bdcdata TO t_bdcdata.
    ENDIF.                                 " IF P_PACK EQ '$TMP'
    CALL TRANSACTION 'SE38' USING t_bdcdata MODE 'E'.
    Hope this would help you..
    Regards
    Narin Nandivada

  • Conv. based on the month - Need to display the output in quarterly basis.

    Hi Gurus,
    I need to display the output quarterly based on the month.
    For example,
    If the year is 2012 and month is between
    01 to 03 i need to display it as 2012Q1
    likewise 04 to 06 as 2012q2
    and 07 to 09 as 2012q3
    and 10 to 12 as 2012q4.
    Please help me by providing sample codes. Please help yourself by writing the code and get back when you have a specific question.
    Thanks!
    Regards,
    Manoj
    Edited by: kishan P on Mar 2, 2012 3:14 PM

    Hi Vinod
    To get the last 13 months in webi report .follow below approach
    Assuming you have calendar Month object in the report.
    convert your selected date into M/d/yy format . let's say you selected 12/18/13 , your variable should be 12/1/13
    variable :
    Selected Month =ToDate(FormatDate(useresponse("Date");"Mmm yyyy");"Mmm yyyy")
    Flag for month     =ToDate([CalMonth];"Mmm yyyy")<=[Selected Month]
    Report filter          =[Flag for month]+Previous(Self)
    select the table you want to filter
    add filter -> Report filter between 1 to 13.
    Hope this will help.

  • I am trying to display the output from my ipod touch on apple tv. i can get the audio but no video. please help

    i am trying to display the output from my ipod touch on apple tv. i can get the audio but no video. Thank you for any advice.

    What output are you trying to get to your tv?

  • Problem displaying the output in the same view

    hi Gurus,
    I have developed an web dynrpo application and have three views, in the first view I am having an input field from which I am calling a BAPI by giving that input field value as input to the BAPI.
    Now is it possible to display the output also retrived from the BAPI on the same view.
    Thanks and regards
    kris

    hi LM,
    Thanks for your fast response.
    I think I was not clear in explaining my problem.
    I have a view in which I have an input field which is the input to the BAPI, now on entering the value in the input field I have a submit button, on clicking the BAPI should be executed and also the the output should be displayed on the same view.
    Now regarding the mapping both the input and output are in the same context, would that a problem.
    And also after getting the output from the BAPI I have to do some validations based on the output from the BAPI and get some message printed on the view.
    Please help me in this issue.
    Thanks and regards
    kris

  • // Code Help need .. in Reading CSV file and display the Output.

    Hi All,
    I am a new Bee in code and started learning code, I have stared with Console application and need your advice and suggestion.
    I want to write a code which read the input from the CSV file and display the output in console application combination of first name and lastname append with the name of the collage in village
    The example of CSV file is 
    Firstname,LastName
    Happy,Coding
    Learn,C#
    I want to display the output as
    HappyCodingXYZCollage
    LearnC#XYXCollage
    The below is the code I have tried so far.
     // .Reading a CSV
                var reader = new StreamReader(File.OpenRead(@"D:\Users\RajaVill\Desktop\C#\input.csv"));
                List<string> listA = new List<string>();
                            while (!reader.EndOfStream)
                    var line = reader.ReadLine();
                    string[] values = line.Split(',');
                    listA.Add(values[0]);
                    listA.Add(values[1]);
                    listA.Add(values[2]);          
                    // listB.Add(values[1]);
                foreach (string str in listA)
                    //StreamWriter writer = new StreamWriter(File.OpenWrite(@"D:\\suman.txt"));
                    Console.WriteLine("the value is {0}", str);
                    Console.ReadLine();
    Kindly advice and let me know, How to read the column header of the CSV file. so I can apply my logic the display combination of firstname,lastname and name of the collage
    Best Regards,
    Raja Village Sync
    Beginer Coder

    Very simple example:
    var column1 = new List<string>();
    var column2 = new List<string>();
    using (var rd = new StreamReader("filename.csv"))
    while (!rd.EndOfStream)
    var splits = rd.ReadLine().Split(';');
    column1.Add(splits[0]);
    column2.Add(splits[1]);
    // print column1
    Console.WriteLine("Column 1:");
    foreach (var element in column1)
    Console.WriteLine(element);
    // print column2
    Console.WriteLine("Column 2:");
    foreach (var element in column2)
    Console.WriteLine(element);
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • Can I get a query to get the output data like 4th column instead of 3rd col

    Can I get a query to get the output data like 4th column instead of 3rd column ?
    SQL&gt; select emp.deptno, empno, rownum from emp, dept where emp.deptno=dept.deptno;
    DEPTNO EMPNO ROWNUM
    10 7782 *1* *1*
    10 7839 *2* *2*
    10 7934 *3* *3*
    20 7369 *4* *1*
    20 7876 *5* *2*
    20 7902 *6* *3*
    20 7788 *7* *4*
    20 7566 *8* *5*
    30 7499 *9* *1*
    30 7698 *10* *2*
    30 7654 *11* *3*
    30 7900 *12* *4*
    30 7844 *13* *5*
    30 7521 *14* *6*
    14 rows selected.

    SQL> select emp.deptno, emp.empno,
      2    row_number() over(order by emp.deptno, emp.empno) rn,
      3    row_number() over(partition by emp.deptno order by emp.empno) dept_rn
      4  from emp, dept
      5  where emp.deptno=dept.deptno
      6  order by emp.deptno, emp.empno;
        DEPTNO      EMPNO         RN    DEPT_RN
            10       7782          1          1
            10       7839          2          2
            10       7934          3          3
            20       7369          4          1
            20       7566          5          2
            20       7788          6          3
            20       7876          7          4
            20       7902          8          5
            30       7499          9          1
            30       7521         10          2
            30       7654         11          3
            30       7698         12          4
            30       7844         13          5
            30       7900         14          6
    14 rows selected.Regards,
    Dima

  • How to reinitialize the sel screen after displaying the output..?

    Hi All,
    I have a report program. In the selection screen, I will provide the input parameters and execute the program which displays the output on the screen. Now, if I come BACK to the selection screen, the values which I entered earlier will appear on the selection screen. My requirement is... If I come BACK from the output screen to the selection screen, the selection screen should be blank. I mean, all the values I entered earlier should be cleared. Could anyone please tell me how to do that.
    Thanks in advance.
    Best regards,
    Paddu.

    Hi Paddu,
    the selection screen will be reinitialized automatically. Only if the INITIALIZATION event or the parameters use SET/GET parameter IDs (addition MEMORY ID pid) the values will prevail.
    You may clear everything in INITIALIZATION event.
    Regards,
    Clemens

  • Display the output in horizontally insted of vertical as per date

    hi
    experts
    display the output in horizontally insted of vertical as per date.
    Date :    From ..........  To  .............
    work center         yeild to confrorm                                    date
    W1                         288                                               1.4.2009
                                  256                                                3.4.2009
    Eg
    workcenter    date :   01.04.2009      2.04.2009    3.04.2009    4.04.2009  .......................
      W1                           288                                 256  
        w2                           234                345                               345

    Hi,
    Incase you have to display this in an ALV; then your internal table will be dynamic.
    Your internal table will consists of following fields
    Work Centre
    Date1
    Date2
    DateN
    The date columns will not be of type d but rather character as in this columns you have to store the workcentres in them.
    Create your dynamic internal table using the class CL_ALV_TABLE_CREATE and method CREATE_DYNAMIC_TABLE.
    You will have to create a fieldcatalog table and pass to the method.
    Then use the dynamic internal table created to store your data horizintally against each date column.
    Display the output in an ALV.
    Pass the date values as the description for each date column in the ALV.
    I hope you get the concept.
    Regards,
    Ankur Parab
    Edited by: Ankur Parab on Jun 23, 2009 4:24 PM

  • Run or display the output in Oracle developer form runtime web

    Hi guys,
    I have installed oracle forms10g in windows 7. im using firefox v.2. when i run the form, the Oracle developer form runtime web is not opening. the output is display in the mozilla firefox itself.
    but how to run or display the output in Oracle developer form runtime web?
    Thanks in advance

    What's the problem? What do you mean with the form, the Oracle developer form runtime web is not opening and the output is display in the mozilla firefox itself?
    Is the Form open or not? If you see you form, where ever, then the "runtime" is running!
    Is it displays within the browser window? But you expected it in an own window?
    If that's the case you have to set separateFrame = TRUE in fomsweb.cfg.

  • Are You All Able to get the Output In EXCEL Format

    Hi All,
    I have one question. Are You All Able to get the Output In EXCEL Format?? I am working on Oracle Apllication 11.5.10.2 and my XML builder is 5.0.1. Problem which i m facing is this...... Whenever i am submitting a concurrent program with format type different from PDF i could not able to view the ouput in desired format. When i am pressing view output it gives me a file in XML and when i save that file with extention 'xls' or 'rtf' then i could able to see the saved file in desired format.
    Can anyone tell me where is the problem??? Is it a bug?
    I am using microsoft world 2000 sp-3.
    Please give your valuable comments. May be your comments can solve my problem..
    Thanks
    Ravi

    Hi I got Same issue
    When I change Format to EXCEL from
    Submit request>> Option>> Format = EXCEL
    In window I am getting something HTML code and
    when I try to copy it to Browser from Tools>> Copy File in to Browser I am getting following message
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    End tag 'p' does not match the start tag 'a'. Error processing resource 'http://our url.com:8000/OA_CGI...
    <p class="c0"><a name="Text4" id="Text4"><a name="Text1_1" id="Text1_1"><span class="c1">Dept No <...
    But I can see the output when Format is PDF
    Pls suggest solution ,I am using EBS 11.5.10.2.
    Thanks
    Rahul
    Message was edited by: Rahul
    user576181

Maybe you are looking for

  • How to automate full online SQL to tape/device (daily)

    Dear all, In my company, daily backups is of 2 types. 1. from Db13 SAP level backup full online to tape. 2. from SQL , full online to disk. Db13 jobs we schedule in SAP. But, i want to automate the SQL level full online backup to device.(External USB

  • Listbox and POV on WEB Dynpro

    Hi guru. Can it is possible create an help in POV for a listbox field on WEB ABAP Dynpro? If it is possible, can I realize it? Regards Angela

  • Export Catalog - Virtual Copies

    Hi. If you export a group of photos as a Catalog, does this export all virtual copies including their own repsective xmp data? I need to send a batch of RAW files to someone but need them to be able to see all the virtual copies as well.

  • Can Audigy 2 NX be used disconnected from comput

    I'm thinking about buying an Audigy 2 NX and am wondering whether, once set up, it be used to upmix a stereo a source plugged into the Audigy 2 NX's line in, to 4./5./6./7. channels (by enabling CMSS with remote or with the EAX console) if the Audigy

  • IMac Intel 17" 1.83Ghz *BUYING ADVICE*

    Mac users, I'm about to purchase an Intel iMac 17" 1.83Ghz with 1MB of RAM (DVD-R, X1600) - primarily for the iLife suite, especially Garageband and iMovie / iDVD. But BEFORE I purchase, I wondered if anyone might have any kindly advice, such as: iDV