Reg: Function NTILE -

Hi Experts,
I was going through the function(s) in Oracle docs which I have never used, to learn something new.
Got a doubt - What is the actual/practical use of function - NTILE ?
I tried playing with it and understood it's working but a practical example will give a better understanding.
Also, another curious question - What can be the scenario where after distributing the rows equally amount 'x' buckets, the remainder rows are distributed 1 each serially in all buckets?
ranit@XE11GR2>> select * from x1;
      COL1       COL2 COL3                           COL4
         1       1401 a1                             aa1
         2        102 a2                             aa2
         3        103 a3                             aa3
         4        104 a4                             aa4
         5        105 a5                             aa5
         6        101 a1                             aa1
         7        107 a7                             aa7
         8        101 a1                             aa1
         9        109 a9                             aa9
        10        102 a2                             aa2
        11        101 a1                             aa1
        12        101 a1                             aa1
12 rows selected.
Elapsed: 00:00:00.14
ranit@XE11GR2>> select col1, col2, col3, col4,
  2  NTILE(5) OVER(order by col2) nt
  3  from x1;
      COL1       COL2 COL3  COL4           NT
         6        101 a1    aa1             1
        11        101 a1    aa1             1
         8        101 a1    aa1             1
        12        101 a1    aa1             2
        10        102 a2    aa2             2
         2        102 a2    aa2             2
         3        103 a3    aa3             3
         4        104 a4    aa4             3
         5        105 a5    aa5             4
         7        107 a7    aa7             4
         9        109 a9    aa9             5
         1       1401 a1    aa1             5
12 rows selected.
Any help regarding this is much appreciated.
Regards
-- Ranit
(on Oracle version 11.2.0.2.0)

I meant using ntile for computing quantiles.
with
data_table as
(select trunc(dbms_random.value(10,100)) outcome
   from dual
connect by level <= :trials
select outcome,
       ntile_q,
       case when lead(ntile_q) over (order by outcome) - ntile_q > 0
            then 0.5 * (lead(outcome) over (order by outcome) + outcome)
       end q_tile
  from (select outcome,
               ntile(:q) over (order by outcome) ntile_q
          from data_table
order by outcome
OUTCOME
NTILE_Q
Q_TILE
13
1
23
1
28
1
29.5
31
2
36
2
37
2
38.5
40
3
49
3
51
3
53
55
4
57
4
64
4
67
70
5
71
5
76
5
77
78
6
79
6
81
6
87
93
7
97
7
Regards
Etbin

Similar Messages

  • Reg Function module for getting date

    Hi,
    My requirement is, If I entered some date I need to get past three months number of days.
    Eg: if I entered 26thDec,2007
    I need to get number of days form October 1st to 26th Dec.
    Regards,
    sarath.

    try this code
    REPORT ztest .
    DATA : lv_date TYPE syst-datum ,
           lv_tmp  TYPE i          .
    PARAMETERS : p_date TYPE syst-datum OBLIGATORY .
    CALL FUNCTION 'ADD_TIME_TO_DATE'
      EXPORTING
        i_idate = p_date
        i_time  = '3'
        i_iprkz = '2' "Month
      IMPORTING
        o_idate = lv_date.
    lv_tmp = lv_date - p_date .
    WRITE : 'Diff in days ' , lv_tmp .

  • Reg:Function module SAPWL_GET_SUMMARY_STATISTIC not working in CRM ABAP 6.0

    Hi All,
      When i execute the function module SAPWL_GET_SUMMARY_STATISTIC in CRM ABAP 6.0 passing the values below,
    PERIODTYPE                    
    HOSTID                         
    STARTDATE  
    it's not showing any values in the summary.
    it's showing the exporting parameters as,
    RFC_ERROR_TYPE                  L
    SUMMARY_AVAILABLE               N
    HITLISTS_N_PROFILES_AVAILABLE   A
    if this function module will not work means kindly provide me the solution for calculating
    Average Response Time as in tcode st03 - Instance - total - Workload Overview.
    Average CPU Time and some more fileds.
    Regards,
    Suresh

    Hi
    I used the FM mentioned and found the details as below:
    VKORG
    TABNAME                        TVKO
    FIELDNAME                      VKORG
    LANGU                          EN
    POSITION                       0001
    OFFSET                         000006
    DOMNAME                     VKORG
    ROLLNAME                    VKORG
    CHECKTABLE
    VTEXT
    TABNAME                        TVKOT
    FIELDNAME                      VTEXT
    LANGU                          EN
    POSITION                       0002
    OFFSET                         000014
    DOMNAME                        TEXT20
    ROLLNAME                       VTXTK
    CHECKTABLE
    LENG                           000020
    Shiva

  • Reg: Function Module thats used to check the status of JOBS and mail it

    Hi Experts,
    Is there any Standard Function module thats going to find the status of the jobs and mail this status to specied email ID in .xls format. While checking status function module should give whether job is - Aborted, Successful, Running, Waiting, Locked, Error, Warning, Starting Date, Ending Date of the Job.
    Please help me,

    Hello Nagaraj,
    You can find out the status of a job with the SHOW_JOBSTATE function module. You provide this function module with a job name and job number. It returns one of the six possible statuses of the job:
    ABORTED TYPE C,
    FINISHED TYPE C,
    PRELIMINARY TYPE C,
    READY TYPE C,
    RUNNING TYPE C,
    SCHEDULED TYPE C.
    Following is the link for the same:
    http://help.sap.com/saphelp_sm32/helpdata/en/fa/096e10543b11d1898e0000e8322d00/content.htm
    Warm Regards,
    Riki Dash

  • Reg function module POSTING_INTERFACE_CLEARING

    Dear experts,
    I have a requirement in tcode FB05(Posting with clearing: Initial screen).  In that i need to select the radio button 'Transfer Posting with Clearing'.  I dont know exactly what happens here. I have to use function module POSTING_INTERFACE_CLEARING to post and clear the document. Can anybody tell me what this function module will do and by guiding me in this regard. Kindly help me in giving sample code as to how to handle this.
    thks in advance,
    ram

    Hello Ram
    Have a look at thread [POSTING_INTERFACE_CLEARING|POSTING_INTERFACE_CLEARING; and the links provided there.
    You may also want to have a look at transaction FCC1 (Payment Cards: Settlement). The report RFCCSSTT is used to settle open items payed with credit cards:
        ... FB05
          PERFORM posting_interface_start.
          PERFORM fb05_posting.
          PERFORM posting_interface_end.
        ... and Settlement
    Regards
      Uwe

  • Reg: Functions of Planning Table MF50

    Hi Friend,
    i wish you all a happy Friendship day...
    I need to know the following Function in REM,
    1. Functions of Planning table.(MF50)
    2.When we carry out Backflush , Components , activities get Posted. where can i find the reports for activities and components posted.
    3. Preliminary Costing Values.
    Thanks in advance.

    Hi dayanan,
    1. Planning table MF50 is used to create a manual planned order respective date wise inspite of creating in MD11 one by one.
    2. When you assembly backflush in MFBF your component consumption and Activities will get posted automatically GI, GR & Activities will be posted. This component consumption you can see through movement type 261 in MB51. Cost of that consumption and activities you can monitor in Product cost collector. PPC. for that go to KKF6N-select version- Header---- costs.... There you can refer the updated cost of consumption and MHR.
    3. If you to consume additional component without GR that means only GI, goto MFBF and select component backflush and enter the component which you want to consume.
    Hope this will clear all your doubts.
    Regards,
    Santhosh.

  • Reg: Function Module

    Hi All,
         I am creating a function module to update data into a customized table. In that funciton module, i want to handle exception. But i dont know how to proceed with that.
       Can you please any one help me out in this regard.
    POINTS PROMISED.
    Regards,
    Buvana

    Hi,
    After calling function module write.
    if sy-subrc <> 0
    RAISE EXCEPTION.
    endif.
    Reward if helpful.
    Regards,
    Umasankar.

  • Reg Function Module to Date Calculation

    Hi,
    Could anybody assist me, My requirement is to determine delay of delivery date is equal to (goods receipt posting date u2013 planned delivery date).Is there any function module to find out the dated diffrence. The difference should be '+' or '-' OR 'ZERO'
    Thanks in advance.
    Regards.
    I.Reddy Prasad.

    Hi,
    Use this Function Module  'FIMA_DAYS_BETWEEN_TWO_DATES'. 
    Reward If Helpfull,
    Naresh.

  • Reg function module to get  periods.

    Hi,
        can any one help me in giving the function module to get the number of months  available in between the start date and end date
    Regards.
    venkat

    Hi,
    Use the below function modules.
    HR_ECM_GET_NUMBER_OF_MONTHS
    HR_GBSXP_GET_MONTHS
    For the function module HR_GBSXP_GET_MONTHS Pass 'M'
    for MODIFY_INTERVAL.

  • Reg:function module to retrive the ekko table data

    Hi all,
    Is there any function module to retrive the ekko table data for the given select-options and parametrs.
    could you provide that.
    Thanks & regards,
    S.chaitanya.

    dear chaitanya,
    may be you can use this function module ME_READ_EKKO_MULTIPLE which can be used to pass the select options to retrieve the desired EKKO data.
    OR the best way would be to do a SELECT Query which would retrieve the data faster and in an effective manner.
    Hope this helps you.
    Help Children of U.N World Food Program by rewarding and enocourage others to answer your queries
    Thanks
    Venugopal

  • Reg:- function.

    hi friends,
    my problem is i have one store function like example below.
    Function Func1 (Empid in varchar2) RETURN VARCHAR2
    As
    SELECT DEPTNAME,DESIGNATION FROM EMPLOYEE WHERE EMPLOYEEID=EMPID;
    END;
    ABOVE FUNCTION RETURN ME DEPTNAME AND DESIGNATION OF PASSING EMPLOYEEID.
    AND RETURN OUTPUT LIKE....."SALES,EMP" IN ONE COLUMN
    THEN I WANT PASS THIS BOTH THE VALUE IN MY PROC..HOW CAN I PASS BOTH THE DIFFERENT.
    BECAUSE MY PROC HAVING PARAMETER LIKE BELOW...
    PROCEDURE PROC1 (Deptid,desig)
    AS
    begin
    end;
    --Rajnish                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    What a shame you didn't provide a complete example - your example code has syntax errors!
    Why bother calling your function in your procedure - why not just have one select statement that gets the results? It'll be quicker...

  • Reg function modules in scripts

    Hi,
      <b>wat happens if we dont use open_form , start_form , close_form...
    which is mandatory function module and which optional functional module ???
    wat happends if we dont use close_form?</b>pls tel me its really urgent
    pls
    Thanx in Advance..

    Hi,
    wat happens if we dont use open_form , start_form , close_form...
    For open the form open form should be there other wise we can't run the script.
    which is mandatory function module and which optional functional module ???
    Start-form is optional and opne_form and lose_form is manditory FMs. same as write_form also.
    wat happends if we dont use close_form?
    If you don't use close_form then while running the script you will get error.
    Hope this helps you, reply for queries, Shall post you the updates.
    Regards. 
    Kumar. .

  • Reg Function Module / BAPI

    Xperts,
    I have to create a wrapper RFC fn module ...
    The input parameter is matnr,sales area , sold to,ship to..
    and the return parameters are
    MSRP (rate based on price list)
    material Availability
    Status from MARA-MSTAV
    Valid To / From MARA-MSTDE
    (i got rest of the fields i got already from BAPI_MATERIAL_GETALL)
    Thanks & Regards,
    Anoop Chandran

    Use data Element : GLX_XFELD ( General Checkbox ) for checkbox..
    For check box... if box is checked then value is 'X' else
    space.
    but in function module it doesn;t matter whether u use data element for checkbox...  u can use char type variable of length 1.
    and inside code u can check..
    v_char1 = 'X'. : it means checkbox is checked.
    v_char1 = space " it means checkbox not checked.
    Reward if useful
    regards
    Prax

  • Reg: Functionality of non standard screen

    Hi
    My client wants to enter serial number of final product and its sub assembly parts in a separate development T-code (Z or Y t-code). This is will be done after inspection by quality person.
    For developing the screen, what are the things i need to give for ABABer. I mean functionality requirement.
    Please advice..
    Janardhanan

    I run 1680x1050 through DVI with no problems.  I used to have to specify a modeline, but that was always tricky...some worked, some didn't, and I never knew which one was the "correct" mode.  Anyway, with the newer releases of Xorg (probably around 5-6 months ago), I don't have to specify a modeline at all.
    As Shaika-Dzari mentioned, you do have to specify the proper horizontal sync and vertical refresh though.  For an example, here is the relevant portion of my <code>xorg.conf</code> file (and my graphics card stuff too, for clarification):
    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Dell"
    ModelName "UltraSharp 2005FPW"
    HorizSync 30.0 - 83.0
    VertRefresh 56.0 - 75.0
    Option "DPMS" "true"
    EndSection
    Section "Device"
    Identifier "Card0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BoardName "GeForce 6200"
    Option "HWCursor" "off"
    Option "IgnoreDisplayDevices" "CRT, TV"
    Option "NoLogo" "true"
    Option "NvAgp" "1"
    Option "RenderAccel" "true"
    Option "AllowGLXWithComposite" "true"
    EndSection
    Section "Extensions"
    Option "Composite" "Enable"
    EndSection
    Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    DefaultDepth 24
    SubSection "Display"
    Viewport 0 0
    Depth 24
    Modes "1680x1050"
    EndSubSection
    EndSection

  • Query reg. function module ERP_IDOC_INPUT_CREDITOR

    Hi Experts,
    Please tell how to pass the parameter of function module ERP_IDOC_INPUT_CREDITOR.
    parameter like input_method,mass processing,pi_xk99_used .
    Thanks,
    sameer

    you can specify any number fields in file and any number fields in internal table,
    see the program and when you specify the count variable in your internal table ,if the data is not available,then it will take some defualt values,other than this one it will be okay.
    In my system count variable data is  538976288  if the file does not have value.
    report x.
    DATA: BEGIN OF ITAB_MATNR OCCURS 0,
    MATNR LIKE MARA-MATNR,
    COUNT TYPE i,
    END OF ITAB_MATNR.
    data : v_repid like sy-repid.
    parameters p_file like rlgrap-filename.
    initialization.
    v_repid = sy-repid.
    at selection-screen on value-request for p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = v_repid
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = p_file
    start-of-selection.
    refresh itab_matnr.
    clear itab_matnr.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = P_FILE
    filetype = 'ASC'
    TABLES
    DATA_TAB = ITAB_MATNR
    EXCEPTIONS
    CONVERSION_ERROR = 1
    FILE_OPEN_ERROR = 2
    FILE_READ_ERROR = 3
    INVALID_TABLE_WIDTH = 4
    INVALID_TYPE = 5
    NO_BATCH = 6
    UNKNOWN_ERROR = 7
    GUI_REFUSE_FILETRANSFER = 8
    OTHERS = 9.
    IF SY-SUBRC <> 0.
    MESSAGE E699(PP) WITH 'Unable to load input file' P_FILE.
    ENDIF.
    in my file
    data is like ( No count)
    matnr
    12344
    ssss
    sddd
    sddff
    after ws_upload :
    material          count
    12344             | 538976288                                             |
    ssss               | 538976288                                             |
    sddd               | 538976288                                             |
    sddff               | 538976288

Maybe you are looking for