How can I get the following results?

Hi, I have a table:
fphm,kshm
2014,00000001
2014,00000002
2014,00000003
2014,00000004
2014,00000005
2014,00000007
2014,00000008
2014,00000009
2013,00000120
2013,00000121
2013,00000122
2013,00000124
2013,00000125
And I want get the following results:
2014,00000001,00000005
2014,00000007,00000009
2013,00000120,00000122
2013,00000124,00000125
And what should the sql is?
Please give me some guide!
Thank you all!

Hi,
Well, what did you say about his :
SQL> select * from tbl;
      FPHM       KSHM
      2014          1
      2014          2
      2014          3
      2014          4
      2014          5
      2014          7
      2014          8
      2014          9
      2013        120
      2013        121
      2013        122
      FPHM       KSHM
      2013        124
      2013        125
13 rows selected.
SQL> select fphm, min(kshm),max(kshm)
  2  from
  3  (select fphm, kshm,
  4          kshm-rank() over (partition by fphm order by fphm,kshm) rk
  5   from tbl)
  6  group by fphm,rk
  7  order by fphm
  8  /
      FPHM  MIN(KSHM)  MAX(KSHM)
      2013        120        122
      2013        124        125
      2014          1          5
      2014          7          9
SQL> insert into tbl values (2013,123);
1 row created.
SQL> select fphm, min(kshm),max(kshm)
  2  from
  3  (select fphm, kshm,
  4          kshm-rank() over (partition by fphm order by fphm,kshm) rk
  5   from tbl)
  6  group by fphm,rk
  7  order by fphm
  8  /
      FPHM  MIN(KSHM)  MAX(KSHM)
      2013        120        125
      2014          1          5
      2014          7          9
SQL> Nicolas.

Similar Messages

  • How can I get the following result?

    Hi, I have table test:
    create table test(oper_date date, income number, expense number), there are several records in this table:
    20060101 100 10
    20060105 200 15
    20060106 150 12
    20060109 30 8
    I want to get the following result:
    20060101 100 10
    20060102 0 0
    20060103 0 0
    20060104 0 0
    20060105 200 15
    20060106 150 12
    20060107 0 0
    20060108 0 0
    20060109 30 8
    How should I write the sql?
    Please give some help!
    Thank you all!

    I used the script below:
    CREATE TABLE mhe_foo( oper_date DATE 
                        , income    NUMBER
                        , expense   NUMBER
    INSERT INTO mhe_foo VALUES(TO_DATE('20060101','YYYYMMDD'), 100, 10)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060105','YYYYMMDD'), 200, 15)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060106','YYYYMMDD'), 150, 12)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060109','YYYYMMDD'),  30,  8)
    SELECT v.oper_date
         , NVL(m.income,0)  AS income
         , NVL(m.expense,0) AS expense
    FROM   ( SELECT  mindt + level - 1 AS oper_date
             FROM    ( SELECT MIN(oper_date) mindt
                            , MAX(oper_date) maxdt
                       FROM   mhe_foo
             CONNECT BY mindt + LEVEL -1 <= maxdt
           ) v
         , mhe_foo m
    WHERE  v.oper_date = m.oper_date(+)
    ORDER BY v.oper_date
    DROP TABLE mhe_foo
    /I saved it as C:\T1\myscript.sql and ran it:
    SQL> @C:\t1\myscript
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    OPER_DATE     INCOME    EXPENSE
    01-JAN-06        100         10
    02-JAN-06          0          0
    03-JAN-06          0          0
    04-JAN-06          0          0
    05-JAN-06        200         15
    06-JAN-06        150         12
    07-JAN-06          0          0
    08-JAN-06          0          0
    09-JAN-06         30          8
    9 rows selected.
    Table dropped.
    SQL>MHE
    Message was edited by:
    maaher

  • How can I get the same result using single query?

    There are 3 tables
    1) tool_desc -
    a master table for storing tool records,
    columns tool_no, tool_chg,
    # of records = 1.5 Millon
    2) step_desc -
    a master table for storing plan wise step records,
    columns plan_id, step_key,
    # of records = 3700 Million
    3) step_tool - a transaction table storing tools to the steps,
    columns plan_id, step_key, tool_no, tool_chg
    For each step in the step_desc table, I need to randomly fetch 1 to 50 tools from tool_desc and insert them into step_tool table.
    Using PL/SQL block, it is like the following -
    begin
    for x in (select plan_id, step_key from step_desc) loop
    insert into step_tool(
    plan_id,
    step_key,
    tool_no,
    tool_chg)
    select
    plan_id,
    x.step_key,
    tool_no,
    tool_chg
    from
    tool sample(0.1)
    where
    rownum <= trunc(dbms_random.value(1,51))
    commit;
    end loop;
    end;
    I need to do the same using a single query so that I can use the CTAS (create table as select) statement and load the data as a bulk.
    Can I do that?

    If they have parent child releation, you can use connect by prior clause,

  • How can i get the external Sql result return data to abap?

    Dear All
             I have a problem to how to get the select  result data return abap.
    I used abap to run external SQL server. below is my code:
    ***in above ,abap has already connected external SQL.
    Sql = u2018select * from user01u2019
          CALL METHOD OF rec 'Open'
            EXPORTING #1 = sql
            #2 = con
            #3 = '1'.
          IF NOT sy-subrc = 0.
            MESSAGE e000 WITH 'run external sql error!'.
          ENDIF.
    ***now ,below code how can I get the select result to abap code?
    I know I can use native_sql  such as u2018OPEN CUR1 FOR SELECT * FROM user01 AND FETCH NEXT CUR1 INTO :WAu2019.
        Thanks for all
    Sun

    Thanks.
    it is okay now by myself.
    con_str = 'Provider=SQLOLEDB.1;Password=pwd;Persist Security Info=True;User ID=name;Initial Catalog=VTL_DEMO;Data Source=192.168.21.50'.
      CREATE OBJECT o_conn 'ADODB.Connection'.
      CREATE OBJECT o_rec 'ADODB.Recordset'.
      SET PROPERTY OF o_conn 'Provider' = provider.
      SET PROPERTY OF o_conn 'ConnectionString' = con_str.
      CALL METHOD OF o_conn 'Open'.
      sql_str = 'select *  from userh'.
      CALL METHOD OF o_conn 'Execute' = o_recordset
        EXPORTING
        #1 = sql_str.
       #2 = o_conn.
      GET PROPERTY OF o_recordset 'EOF' = rs_eof.
      REFRESH itab.
      WHILE rs_eof NE 1.
        CALL METHOD OF o_recordset 'fields' = o_field
          EXPORTING
          #1 = 0.
        GET PROPERTY OF o_field 'Value' = itab-name.
        CALL METHOD OF o_recordset 'fields' = o_field
          EXPORTING
          #1 = 1.
        GET PROPERTY OF o_field 'Value' =  itab-cid.
        APPEND itab.
        CALL METHOD OF o_recordset 'MoveNext'.
        GET PROPERTY OF o_recordset 'EOF' = rs_eof.
      ENDWHILE.

  • Getting the following message on Final Cut Express "audio only capture selected video preview disabled" how can I get the video capture back?

    I'm getting the following message on screen when attempting to capture video  "audio only capture selected, video preview disabled."  How can I get the view preview back?

    FCE doesn't allow for audio only capture, it's in a twist somewhere.
    Try trashing the FCE preferences.
    Al

  • How can i get the time and result together show in one Array or in Cluster?

    hello everyone i am a new user .I want to get the time and voltge form a Generater. How can i get the time and result together show in one Array or in Cluster?When i selecte the first(or third...) result then in the front panel display the time and the voltge.Thank you!
    I post the time and voltge NOT together photo
    Attachments:
    12345.GIF ‏54 KB

    You can create an array of clusters with one element being the time and the other being the voltage, like so (using the "Get Waveform Components" function):
    Message Edited by smercurio_fc on 10-17-2007 03:15 PM
    Attachments:
    pic.PNG ‏11 KB

  • Trying to download OS X Mavericks from App store but the download essentially stalls after downloading about 5.26 GB with a message that it is "calculating."  How can I get the complete download?

    I've tried downloading OS X Mavericks from App store, but the download stalls with a message "calculating."  How can I get the download to finish?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • How can I get the font list of local

    Hi, everyone.
    In AS2.0, I can use TextField.getFontList() to return a
    array that include all font family of local.
    However, AS3.0 no longer supports it. How can I get the font
    list of local in AS3.0?
    Thanks

    thanks, I have been found result from adobe livedocs.
    example code following:

  • I am having macbook air recently my iphotos did not open and was showing report apple and reopen but i came to know that by pressing alt and iphotos i open an new photo library and stored the pics but now how can i get the pics which i had in the earlier

    i am having macbook air recently my iphotos did not open and was showing report apple and reopen but i came to know that by pressing alt and iphotos i open an new photo library and stored the pics but now how can i get the pics which i had in the earlier photo please help me to recover my photos

    Well I'll guess you're using iPhoto 11:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In early versions of Library Manager it's the File -> Rebuild command. In later versions it's under the Library menu.)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  
    Regards
    TD

  • How can we remove the following zeros from quantity field ?

    Hi All.
    how can we remove the following zeros from quantity field while populating ALV by using FM REUSE_ALV_GRID_DISPLAY ?
    eg:getting output zqty = 2.000
    but i need           zqty = 2.
    help me to reslove this issue.
    Regards.
    jay

    Hi,
      While populating the field catlog do the following thing to   avoid zeros.
      wa_fieldcat-tabname = 'I_OUTPUT'.    " Curr
      wa_fieldcat-fieldname = 'FWAER'.
      wa_fieldcat-seltext_l = text-023.
      wa_fieldcat-no_zero = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR  wa_fieldcat.
    Thanks,
    Khushbu.

  • How can we get the values from the view?

    Hi All,
    my scenario is i have two fields in my view .one is parameter.and another on is select-options.how can i get the user entered values into my selection screen.?
    for the select options i get the values into field-symbol.for parameter i get the value using get_attribute.
    can i use like this in select statement.
    WHERE SERVICE_ID  = ZSD_DD_AUFNRS
                       AND CRE_DT IN <FS_DATE>.
    Regards,
    Ravi.

    Hi Sravan,
    when i am using the below code to generate self defined functions i m getting a error .
    *Generate an object for self defined functions
      DATA: lo_self_functions TYPE REF TO if_salv_wd_function_settings,
    *Generate an object for button 'Confirm'
           lr_button TYPE REF TO cl_salv_wd_fe_button,
           lo_self_function TYPE REF TO cl_salv_wd_function,
                  l_text type string.
    *Set Self-defined functions
    *'Confirm' Button
      lo_self_functions ?= l_value..
      lo_self_function = lo_self_functions->create_function( 'CONFIRM'  ).
      CREATE OBJECT lr_button.
      CLEAR l_text.
      l_text = 'Confirm'.
      lr_button->set_text( l_text ).
      lr_button->set_image_source( '' ).
      lr_button->set_image_first( 'X' ).
      lo_self_function->set_editor( lr_button ).
    Error when processing your request
    What has happened?
    The URL http://cgslsvr3.cgsl.com:8020/sap/bc/webdynpro/sap/zsdr_cash_work_list/ was not called due to an error.
    Note
    The following error text was processed in the system CGD : WebDynpro Exception: IDs Can Only Contain Characters of Syntactical Character Set
    The error occurred on the application server cgslsvr3_CGD_20 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: RAISE of program CX_WD_GENERAL=================CP
    Method: CONSTRUCTOR of program CL_WDR_VIEW_ELEMENT===========CP
    Method: CONSTRUCTOR of program CL_WD_TOOLBAR_BUTTON==========CP
    Method: NEW_TOOLBAR_BUTTON of program CL_WD_TOOLBAR_BUTTON==========CP
    Method: IF_SALV_WD_COMP_TABLE_UI~CREATE_TOOLBAR_ITEM of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_UI~CREATE_TOOLBAR_ITEMS of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_UI~UPDATE_TOOLBAR_ITEMS of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_UI~UPDATE_TOOLBAR of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_UI~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    What can I do?
    If the termination type was RABAX_STATE, then you can find more information on the cause of the termination in the system CGD in transaction ST22.
    If the termination type was ABORT_MESSAGE_STATE, then you can find more information on the cause of the termination on the application server cgslsvr3_CGD_20 in transaction SM21.
    If the termination type was ERROR_MESSAGE_STATE, then you can search for more information in the trace file for the work process 0 in transaction ST11 on the application server cgslsvr3_CGD_20 . In some situations, you may also need to analyze the trace files of other work processes.
    If you do not yet have a user ID, contact your system administrator.
    Error code: ICF-IE-http -c: 110 -u: CT-0024 -l: E -s: CGD -i: cgslsvr3_CGD_20 -w: 0 -d: 20080414 -t: 105835 -v: RABAX_STATE -e: UNCAUGHT_EXCEPTION
    HTTP 500 - Internal Server Error
    Your SAP Internet Communication Framework Team
    How can i resolve it?
    Regards,
    Ravi

  • How can I get the XML structure from a flat structure?

    Hi all,
    in my XI SP 12 I use a JMS adapter to read information using the WebSphereMQ transport protocol.
    The structure that I receive have this format:
    <Name_A.KeyFieldValue><Name_A.fieldName_A1_Value>...<Name_A.fieldName_AN_Value>
    <NumberRecordType_B><NumberRecordType_c>
    <Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>
    <Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>
    <Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    <Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    the problem is that in this structure each line is not separated by a carriage return or a comma, I have all the information in a single line:
    <Name_A.KeyFieldValue><Name_A.fieldName_A1_Value>...<Name_A.fieldName_AN_Value><NumberRecordType_B><NumberRecordType_c><Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value>...<Name_B.KeyFieldValue><Name_B.fieldName_B1_Value>...<Name_B.fieldName_BN_Value><Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>...<Name_C.KeyFieldValue><Name_C.fieldName_C1_Value>...<Name_C.fieldName_CN_Value>
    and the customer don't want to insert a line separator.
    Then, the question is:
    How can I get the XML structure from this structure?
    If possible, I don't want to develop new Module and add it in the JMS Module Sequence.
    PS I have already read the article "How to Use the Content Conversion Module with the XI 3 J2EE JMS Adapter.pdf" and it doesn't seem to help me.
    Best Regards,
    Paolo

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • HT1491 I purchased a music album on itunes and it's not listed in my purchased music category.  How can I get the music on my iphone?  I purchased the music through itunes app on my iphone 5.

    I purchased a music album on itunes and it's not listed in my purchased music category.  How can I get the music on my iphone?  I purchased the music through itunes app on my iphone 5.

    Hi Vgreen08,
    Welcome to the Support Communities!
    The following information should help you with this:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/HT1933?viewlocale=en_US
    Cheers,
    Judy

  • How can I get the elapse time for execution of a Query for a session

    Hi ,
    How can I get the elapse time for execution of a Query for a session?
    Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
    Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
    Thanks in advance.

    Hi
    You can use the dbms_utility.get_time tool (gives binary_integer type value).
    1/ Initialize you time and date of beginning :
    v_beginTime := dbms_utility.get_time ;
    2/ Run you procedure...
    3/ Get end-time with :
    v_endTime := dbms_utility.get_time ;
    4/ Thus, calculate elapsed time by difference :
    v_elapsTime := v_endTime - v_beginTime ;
    This will give you time elapsed in of 100th of seconds...
    Then you can format you result to give correct print time.
    Hope it will help you.
    AL

  • How can i get the SMTP IP address for gmail

    Hello,
    sapian,
              I want to schedule a webi document through BI Launch Pad to users email address gmail.So while configuring the AdaptiveJobServer in CMC i need to give SMTP details such as
    Domain name:
    Host:
    Port:
    So for scheduling a webi document to a gmail user i need the above details for gmail SMTP server.Can any one suggest me how can i get the above details for gmail SMTP server.
    Thanks in advance.
    Regards,
    Kishor Kumar S

    Hi Hrishikesh,
    i have configured the 'stunnel.conf' file with the following details
    accept  =static ip address of the machine colon port number where the stunnel is installed
    connect = smtp.gmail.com:465
    and i saved the file.
    when i go to
    Start->Stunnel->service install
    it is giving error as follows
    Error binding ssmtp to (ip address and port number which i have given in stunnel.conf file 'accept')
    bind: No error (0)
    Can you suggest me the solution for the above error.
    Thanks in advance,
    Regards,
    Kishor

Maybe you are looking for

  • Excel export are merging cells for data on multiple lines !

    Hello, I'm using Crystal Report XI R2, when we are doing an export to Excel with have an unexpected formatting. For example the value of the name is on 2 lines: => So, on Excel the result is on 2 lines but merged. We want to have this result only on

  • R/3 tables for the fields of  0fi_gl_40

    How to find the r/3 tables for the fields of the datasource 0FI_GL_40.For example this datasource has ANLN1(Asset),ANLN2(Asset Subnumber) and AUFNR(Order) fields.Is there any tcode or table that gives the r/3 tables for the the fields of the above da

  • Sapscript logo printing reverse

    In a sapscript, I am using a logo. In print preview, its coming fine but when it is printed, it is coming reverse. What could be the problem and possible solutions? I have seen some threads here related to that but I would like to know if those solut

  • Internal Order Budget Exceeded when creating a PO

    Dear all, When we create a PO against an Internal Order, the system displays the message "Item 001 - order X budget exceeded". But checking that order we can see budget available. Do you guys have idea the reason of it? Many thanks, Amanda

  • Playing movies on my insignia tb

    I some movies on my ipad that I'm trying to play on my 42in insignia tv. If I plug just the AV adapter in--the kind with the red, yellow and white plugs--into the av plugs into the tv, it will play for a couple minutes then tell me it doesn't support