How can use row_number() over partition by plz provide some doc.

row_number() over (partition by)
what is this and how can use it in sql query.
if ur have any documentation of it. plz give...me..
thanx sir
thanx in advance.

http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/functions105a.htm
SELECT empno, deptno,
row_number() over (partition by deptno order by empno) rn
from scott.emp
     EMPNO     DEPTNO RN                                    
      7782             10     1
      7839             10     2
      7934             10     3
      7369             20     1
      7566             20     2
      7788             20     3
      7876             20     4
      7902             20     5
      7499             30     1
      7521             30     2
      7654             30     3
      7698             30     4
      7844             30     5
      7900             30     6Regards
Dmytro

Similar Messages

  • Issue with ROW_NUMBER() OVER (PARTITION)

    Hi,
    Please read the Thread completely, I have created a Report to see Yearly Turnover%, The report works fine but when I take Quarter and Months in it, it restricts the result to only 1 line(i.e., my first year's Turnover) and when I opened the Physical query, I saw the BI Server is using
    ROW_NUMBER() OVER (PARTITION BY)
    which is not at all necessary.
    *I tried disabling WITH_CLAUSE_SUPPORTED and PERF_PREFER_MINIMAL_WITH_USAGE but didn't get any resolution, Could anybody help me out?
    thanks in Advance,
    Anand

    You said 'it restricts the result to only 1 line' means the value is nor drill down to next level?
    In that case Yearly Turnover% is set to Year level?

  • How to use SQL OVER and PARTITION BY in OBIEE Expression Builder??

    Hi there,
    I want to create a new logical coulmn with the following SQL query.
    SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C,Inventory Detail.D,MyDATE )/SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C )
    How to use the OVER and PARTITION BY in OBIEE Expression Builder??
    Thanks in Advance

    hi bipin,
    We cant use by in Expression builder(rpd) .But use the same formula like this in Fx of answers
    SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C,Inventory Detail.D,MyDATE )/SUM(Inventory Detail.Qty) >OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C )SUM(Inventory Detail.Qty by Detail,ITEM,Mydate)/SUM(qty by detail,item)
    First check the numerator whether it was giving correct results or not then go with denominator
    compare the results with sql that u have
    Let me know if that does work
    thanks,
    saichand.v
    Edited by: Saichand Varanasi on Jul 27, 2010 9:27 PM
    Edited by: Saichand Varanasi on Jul 27, 2010 9:28 PM

  • Qualify row_number over(Partition by col order by col) and char2hexint() functions in informatica

    How to implement qualify row_number over(Partition by col order by col) and char2hexint in informatica in a way that is supported by pdo?
    Apart from sql overriding or using stored procedure ,is there any other solution?Can rank transformation help here? ....But, I guess rank transformation cannot be pushed down..
    help please !

    Hi Saichand,
    The links were helpful. But i am not getting how it is working in test and not in live.
    I found one difference while deploying . The column names of the object both in Test and Production had spaces.For E.g: Full Name
    When this column Full Name is pulled to the repsository in test , it automatically put double quotes for the column names in the physical sql when it hits the database.
    But, In production , when I pulled the column the report gave error as Invalid Identifier since OBIEE generated column name as Full Name without double quotes.
    Then I changed the column in Phyiscal Layer repository by having double Quotes for all columns. Afte that report worked fine.
    Whether this has caused any issue in Row Partition.
    Is there any setting to have column name in Double Quotes ?
    Thanks,
    Johnny

  • How to use table control in bdc, plz somebody tell me.

    Hi Gurus,
    Ples tell me
    how to use table control in bdc, plz somebody tell me.
    And send Sample CODE also. Thnaks in advance.

    hi,
    Table control / step loop in BDC
    Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen?
    Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')
    we can determine the number of visible lines on Transaction Screen from our Calling BDC program.
    Demo ABAP code has two purposes:
    1. how to determine number of visible lines and how to calculte page number;
    (the 'calpage' routine has been modify to meet general purpose usage)
    2. using field symbol in BDC program, please pay special attention to the difference
    in Static ASSIGN and Dynamic ASSIGN.
    Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop.
    Then have a look at steploop itselp, one entry of it will occupy two lines.
    (Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)
    Now we have : FixedLine = 9
    LoopLine = 2(for table control, LoopLine is always equal to 1)
    Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.
    Now we have: FirstLine = 0
    or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)
    Step3: write a subroutine calcalculating number of pages
    (here, the name of actual parameter is the same as formal parameter)
    global data: FixedLine type i, " number of fixed line on a certain screen
    LoopLine type i, " the number of lines occupied by one steploop item
    FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1
    Dataline type i, " number of items you will use in BDC, using DESCRIBE to get
    pageno type i, " you need to scroll screen how many times.
    line type i, " number of lines appears on the screen.
    index(2) type N, " the screen index for certain item
    begin type i, " from parameter of loop
    end type i. " to parameter of loop
    *in code sample, the DataTable-linindex stands for the table index number of this line
    form calpage using FixedLine type i (see step 1)
    LoopLine type i (see step 1)
    FirstLine type i (see step 2)
    DataLine type i ( this is the item number you will enter in transaction)
    changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)
    changing line type i.(visible lines one the screen)
    data: midd type i,
    vline type i, "visible lines
    if DataLine eq 0.
    Message eXXX.
    endif.
    vline = ( sy-srows - FixedLine ) div LoopLine.
    *for table control, you should compare vline with maximum line of
    *table control, then take the small one that is min(vline, maximum)
    *here only illustrate step loop
    if FirstLine eq 0.
    pageno = DataLine div vline.
    if pageno eq 0.
    pageno = pageno + 1.
    endif.
    elseif FirstLine eq 1.
    pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.
    midd = ( DataLine - 1 ) mod ( vline - 1).
    if midd = 0 and DataLine gt 1.
    pageno = pageno - 1.
    endif.
    endif.
    line = vline.
    endform.
    Step4 write a subroutine to calculate the line index for each item.
    form calindex using Line type i (visible lines on the screen)
    FirstLine type i(see step 2)
    LineIndex type i(item index)
    changing Index type n. (index on the screen)
    if FirstLine = 0.
    index = LineIndex mod Line.
    if index = '00'.
    index = Line.
    endif.
    elseif FirstLine = 1.
    index = LineIndex mod ( Line - 1 ).
    if ( index between 1 and 0 ) and LineIndex gt 1.
    index = index + Line - 1.
    endif.
    if Line = 2.
    index = index + Line - 1.
    endif.
    endif.
    endform.
    Step5 write a subroutine to calculate the loop range.
    form calrange using Line type i ( visible lines on the screen)
    DataLine type i
    FirstLine type i
    loopindex like sy-index
    changing begin type i
    end type i.
    If FirstLine = 0.
    if loopindex = 1.
    begin = 1.
    if DataLine <= Line.
    end = DataLine.
    else.
    end = Line.
    endif.
    elseif loopindex gt 1.
    begin = Line * ( loopindex - 1 ) + 1.
    end = Line * loopindex.
    if end gt DataLine.
    end = DataLine.
    endif.
    endif.
    elseif FirstLine = 1.
    if loopindex = 1.
    begin = 1.
    if DataLine <= Line.
    end = DataLine.
    else.
    end = Line.
    endif.
    elseif loop index gt 1.
    begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.
    end = ( Line - 1 ) * ( loopindex - 1 ) + Line.
    if end gt DataLine.
    end = DataLine.
    endif.
    endif.
    endif.
    endform.
    Step6
    using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control
    form creat_bdc.
    field-symbols: , , .
    data: name1(14) value 'EKPO-EMATN(XX)',
    name2(14) value 'EKPO-MENGE(XX)',
    name3(15) value 'RM06E-SELKZ(XX)'.
    assign: name1 to ,
    name2 to ,
    name3 to .
    do pageno times.
    if sy-index gt 1
    *insert scroll page ok_code"
    endif.
    perform calrange using Line DataLine FirstLine sy-index
    changing begin end.
    loop at DataTable from begin to end.
    perform calindex using Line FirstLine DataTable-LineIndex changing Index.
    name1+11(2) = Index.
    name2+11(2) = Index.
    name3+12(2) = Index.
    perform bdcfield using DataTable-matnr.
    perform bdcfield using DataTable-menge.
    perform bdcfield using DataTable-indicator.
    endloop.
    enddo.
    example 1
    BDC table control is an area on the screen in which you can display data in tabular form. You process it using a loop. Table controls are comparable to step loop tables. While a table control consists of a single definition row, step loop blocks may extend over more than one row. Table controls are more flexible than step loops, and are intended to replace them
    When you need to handle a scenario like in sales order,it may contain more than one material,if you have more than one material We have to use table control,it will have number of columns and number of rows.
    Table controls allow you to enter, display, and modify tabular data easily on the screen
    Check this code,
    PARAMETERS: file1 LIKE rlgrap-filename.
    *Internal Table Declarations
    DATA: BEGIN OF itab OCCURS 0,
    matnr(18) TYPE c, "MaterialNumber
    werks(4) TYPE c, "Plant
    vdatu(10) TYPE c, "Valid From Date
    bdatu(10) TYPE c, "Valid To Date
    lifnr(10) TYPE c, "Vendor Number
    ekorg(4) TYPE c, "Purchasing Organization
    feskz TYPE c, "Fixed
    autet TYPE c, "MRP Indicator
    END OF itab.
    DATA: bdcdata LIKE TABLE OF bdcdata WITH HEADER LINE.
    *VARIABLES Declarations
    DATA: wa1 LIKE LINE OF itab. "Workarea for ITAB
    DATA: n TYPE i, "Check
    count TYPE i.
    DATA: cnt(2), "Counter
    wa(15). "Workarea to hold concatenatedvalue
    DATA v_msg(100).
    DATA: flag.
    DATA: file TYPE string.
    *Initialization event
    INITIALIZATION.
    *At-selection-screen event
    *To provide Input help for file name
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file1.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = file1.
    *START-OF-SELECTION EVENT
    START-OF-SELECTION.
    MOVE file1 TO file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file
    filetype = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *To populate BDCDATA and start data transfer
    LOOP AT itab .
    To validate Plant range
    IF itab-werks = '1000' OR itab-werks = '2000'
    OR itab-werks = '1008'.
    AT NEW werks.
    CLEAR: n.
    cnt = 1.
    PERFORM bdc_dynpro USING 'SAPLMEOR' '0200'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'EORD-MATNR'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'EORD-MATNR'
    itab-matnr.
    PERFORM bdc_field USING 'EORD-WERKS'
    itab-werks.
    PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
    CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
    PERFORM bdc_field USING 'BDC_CURSOR'
    wa.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=BU'.
    ENDAT.
    IF n = 12.
    READ TABLE bdcdata WITH KEY fval = '=BU'.
    bdcdata-fval = '=NS'.
    MODIFY bdcdata INDEX sy-tabix TRANSPORTING fval.
    PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'EORD-VDATU(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=BU'.
    cnt = 2.
    n = 2.
    ENDIF.
    CONCATENATE 'EORD-VDATU(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-vdatu.
    CONCATENATE 'EORD-BDATU(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-bdatu.
    CONCATENATE 'EORD-LIFNR(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-lifnr.
    CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-ekorg.
    CONCATENATE 'RM06W-FESKZ(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-feskz.
    CONCATENATE 'EORD-AUTET(' cnt ')' INTO wa.
    PERFORM bdc_field USING wa
    itab-autet.
    IF n <> 12.
    n = cnt.
    ENDIF.
    cnt = cnt + 1.
    AT END OF werks.
    CALL TRANSACTION 'ME01' USING bdcdata
    UPDATE 'S'
    MODE 'A'.
    CLEAR:bdcdata,bdcdata[].
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    id = sy-msgid
    lang = 'EN'
    no = sy-msgno
    v1 = sy-msgv1
    v2 = sy-msgv2
    v3 = sy-msgv3
    v4 = sy-msgv4
    IMPORTING
    msg = v_msg.
    WRITE:/ v_msg.
    CLEAR: bdcdata,bdcdata[],flag.
    ENDAT.
    ENDIF.
    ENDLOOP.
    Start new screen *
    FORM bdc_dynpro USING program dynpro.
    CLEAR bdcdata.
    bdcdata-program = program.
    bdcdata-dynpro = dynpro.
    bdcdata-dynbegin = 'X'.
    APPEND bdcdata.
    ENDFORM.
    Insert field values
    FORM bdc_field USING fnam fval.
    IF NOT fval IS INITIAL.
    CLEAR bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    APPEND bdcdata.
    ENDIF.
    CLEAR wa.
    ENDFORM.
    Sample code 2
    THis is example to upload the Bank details of the Vendor which has the TC.
    REPORT zprataptable2
    NO STANDARD PAGE HEADING LINE-SIZE 255.
    DATA : BEGIN OF itab OCCURS 0,
    i1 TYPE i,
    lifnr LIKE rf02k-lifnr,
    bukrs LIKE rf02k-bukrs,
    ekorg LIKE rf02k-ekorg,
    ktokk LIKE rf02k-ktokk,
    anred LIKE lfa1-anred,
    name1 LIKE lfa1-name1,
    sortl LIKE lfa1-sortl,
    land1 LIKE lfa1-land1,
    akont LIKE lfb1-akont,
    fdgrv LIKE lfb1-fdgrv,
    waers LIKE lfm1-waers,
    END OF itab.
    DATA : BEGIN OF jtab OCCURS 0,
    j1 TYPE i,
    banks LIKE lfbk-banks,
    bankl LIKE lfbk-bankl,
    bankn LIKE lfbk-bankn,
    END OF jtab.
    DATA : cnt(4) TYPE n.
    DATA : fdt(20) TYPE c.
    DATA : c TYPE i.
    INCLUDE bdcrecx1.
    START-OF-SELECTION.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = 'C:\first1.txt'
    filetype = 'DAT'
    TABLES
    data_tab = itab.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = 'C:\second.txt'
    filetype = 'DAT'
    TABLES
    data_tab = jtab.
    LOOP AT itab.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'RF02K-KTOKK'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'RF02K-LIFNR'
    itab-lifnr.
    PERFORM bdc_field USING 'RF02K-BUKRS'
    itab-bukrs.
    PERFORM bdc_field USING 'RF02K-EKORG'
    itab-ekorg.
    PERFORM bdc_field USING 'RF02K-KTOKK'
    itab-ktokk.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFA1-LAND1'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'LFA1-ANRED'
    itab-anred.
    PERFORM bdc_field USING 'LFA1-NAME1'
    itab-name1.
    PERFORM bdc_field USING 'LFA1-SORTL'
    itab-sortl.
    PERFORM bdc_field USING 'LFA1-LAND1'
    itab-land1.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFA1-KUNNR'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKN(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    cnt = 0.
    LOOP AT jtab WHERE j1 = itab-i1.
    cnt = cnt + 1.
    CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-banks.
    CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-bankl.
    CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-bankn.
    IF cnt = 5.
    cnt = 0.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=P+'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKN(02)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    ENDIF.
    ENDLOOP.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB1-FDGRV'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'LFB1-AKONT'
    itab-akont.
    PERFORM bdc_field USING 'LFB1-FDGRV'
    itab-fdgrv.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB1-ZTERM'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB5-MAHNA'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFM1-WAERS'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'LFM1-WAERS'
    itab-waers.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'RF02K-LIFNR'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=YES'.
    PERFORM bdc_transaction USING 'XK01'.
    ENDLOOP.
    PERFORM close_group.
    Header file:
    1 63190 0001 0001 0001 mr bal188 b in 31000 a1 inr
    2 63191 0001 0001 0001 mr bal189 b in 31000 a1 inr
    TC file:
    1 in sb 11000
    1 in sb 12000
    1 in sb 13000
    1 in sb 14000
    1 in sb 15000
    1 in sb 16000
    1 in sb 17000
    1 in sb 18000
    1 in sb 19000
    1 in sb 20000
    1 in sb 21000
    1 in sb 22000
    2 in sb 21000
    2 in sb 22000
    Regards

  • ROW_NUMBER() OVER (PARTITION

    hi, can anyone explain, especially this part
    ROW_NUMBER() OVER (PARTITION BY A.USER_ID ORDER BY A.TNP_TRACK_ID DESC) RN
    Thanks
    newbie
    SELECT A.TNP_TRACK_ID, A.USER_ID, NVL(A.DELETED,0) DELETED, A.CREATE_TIME, A.DELETE_TIME, B.PRODUCT_CODE, C.LOGIN_NAME,
    ROW_NUMBER() OVER (PARTITION BY A.USER_ID ORDER BY A.TNP_TRACK_ID DESC) RN
    FROM MISPNA.TNP_TRACKABLE_' || TO_CHAR(p_reporting_month, 'YYYYMM') || ' A
    JOIN TMP_VRZ_LATEST_SOC B ON A.TNP_TRACK_ID = B.TRACK_ID
    JOIN MISPNA.TN_LOGIN C ON A.USER_ID = C.USER_ID
    WHERE A.DELETED<>1

    Hi,
    949523 wrote:
    thank you very much, the whole original script is
    SELECT TNP_TRACK_ID, USER_ID, DELETED, CREATE_TIME, DELETE_TIME, PRODUCT_CODE, LOGIN_NAME
    FROM (
    SELECT A.TNP_TRACK_ID, A.USER_ID, NVL(A.DELETED,0) DELETED, A.CREATE_TIME, A.DELETE_TIME, B.PRODUCT_CODE, C.LOGIN_NAME,
    ROW_NUMBER() OVER (PARTITION BY A.USER_ID ORDER BY A.TNP_TRACK_ID DESC) RN
    FROM MISPNA.TNP_TRACKABLE_' || TO_CHAR(p_reporting_month, 'YYYYMM') || ' A
    JOIN TMP_VRZ_LATEST_SOC B ON A.TNP_TRACK_ID = B.TRACK_ID
    JOIN MISPNA.TN_LOGIN C ON A.USER_ID = C.USER_ID
    WHERE A.DELETED <>1
    WHERE RN != 1';I assume the single-quote near the end is just an editing typo.
    >
    so seems like with specified user_id, it will pick greatest tnp_track_id ? ( as it asks RN=1)That's what it would be doing if the last line read
    WHERE  rn = 1; for each user_id, that query (with = on the last line) would display all the SELECTed values from the row with the greatest tnp_track_id.
    Since you're using != , however, then it's doing just the opposite; it's displaying all rows except the row with the greatest tnp_track_id.
    The sub-query is necessary here. All analytic functions, including ROW_NUMBER, are evaluated after the WHERE clause has been applied. To use the results of an analytic function in a WHERE clause, you have to compute the function in a sub-query first.
    Edited by: Frank Kulash on Jan 7, 2013 8:08 PM
    Just noticed you're saying "WHERE RN != 1" ( not equals)

  • Convert SQL Server ROW_NUMBER() OVER(PARTITION BY() Query to Access

    Hi,
    I am having trouble with converting this SQL Server query to Access. If anyone can give me help I would appreciate it.
    SELECT B.AMOUNT_REQUESTED, B.INIT_OFF, B.MBR_NBM, B.STATUS, B.APPLICATION_NBR
    FROM
    SELECT AMOUNT_REQUESTED, INIT_OFF, MBR_NBM, STATUS, APPLICATION_NBR, ROW_NUMBER() OVER(PARTITION BY MBR_NBM ORDER BY MBR_NBM) RN
    FROM LOAN_DATA
    WHERE APPLICATION_DATE BETWEEN '20150420' AND '20150425'
    ) B
    WHERE RN = 1
    ORDER BY B.MBR_NBM

    While there is no equivalent to ROW_NUMBER(), it appears that you are just wanting the first row of each group, and that CAN be accomplished in Access, but I do wonder why you would WANT to do that in Access if your data is stored in SQL Server.  As
    Tom indicated a Pass Through query object is likely your best bet -- or a View in SQL Server, then create a Linked Table object that points to it.
    To get the first of each group ... which is essentially a TOP n, where n = 1 ... so .. the first thing you will want to indentify is a second field to use as a Key in order to define the "first" row you want in the group.  In your SQL
    statement, you are ordering my mbr_nbm, so the secondary sort is unknown -- likely predicable, but unknown with out knowledge of the schema ... so, I will provide samples by using APPLICATION_DATE as the sort key.
    This one is the "first" of a series with the assumption that the one you want is the one with the "biggest"/"most recent" APPLICATION_DATE. 
    SELECT vLoanData.AMOUNT_REQUESTED, vLoanData.INIT_OFF, vLoanData.MBR_NBM, vLoanData.STATUS, vLoanData.APPLICATION_NBR
    FROM LOAN_DATA As vLoanData
    INNER JOIN
    (SELECT MBR_NBM, Max(APPLICATION_DATE) As LastAppDate
    FROM LOAN_DATA As vLast
    GROUP BY MBR_NBM) As vLastApp ON vLoanData.MBR_NBM = vLastApp.MBR_NBM And vLoadData.APPLICATION_DATE = vLastApp.LastAppDate
    Or ... the following is a TOP n query where n = 1.
    SELECT vLoanData.AMOUNT_REQUESTED, vLoanData.INIT_OFF, vLoanData.MBR_NBM, vLoanData.STATUS, vLoanData.APPLICATION_NBR
    FROM LOAN_DATA As vLoanData
    WHERE (vLoanData.MBR_NBM & '|' & vLoanData.APPLICATION_DATE)
    IN (SELECT TOP 1 (vCorrelated.MBR_NBM & '|' & vCorrelated.APPLICATION_DATE) As Key
    FROM LOAN_DATA As vCorrelated
    WHERE vCorrelated.MBR_NBM = vLoanData.MBR_NBM
    ORDER BY vCorrelated.MBR_NBM, vCorrelated.APPLICATION_DATE DESC)
    This second example is not going to win you any points with respect to speed, but is truly a closer model to the TOP N type thing you are doing in SQL Server.
    Hope that helps!
    Brent Spaulding | Access MVP

  • I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?

    I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?
    I have tried bootcamp and have had no luck due to the fact that boot camp doesn't see the additional HDD space of 250Gb. What am I not doing?

    Ouch, well there is a problem.
    This is the stack of partitions on your old drive
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    This is the same stack on your new drive imaged from the old one.
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    Emtpy Space (100GB say)
    This is what you want
    EFI (hidden)
    Lion (100GB say)
    Bootcamp (100GB say)
    Lion Recovery Partiton (hidden)
    EFI has to be at the top of the drive and Lion Recovery has to be at the bottom of the drive.
    And you only have four partitions.
    You can't move the Lion Recovery Partition or Bootcamp partiton, however you can expand the Lion Partition into empty space below it. (but can't delete or move the Lion Recovery partition)
    Your Duplicator duplicated perfectly, too perfectly Likely would work with same sized drives/partitions.
    This is what your going to need to do.
    You need to move the Bootcamp partition to a blank external drive using WinClone and disconnect. This is so you have two backups of it. (one on your old 500GB drive)
    You will need a drive enclousre or IDE/SATA to USB adapter cable for the older 500GB drive and option key boot from it. (some enclosures can't be booted from so check first Other World Computing is good place to ask)
    Download the free Carbon Copy Cloner, grab any new files off the new 750GB internal drive to the old 500GB your booted from.
    Open Apple's Disk Utility and Erase with Zero option the entire internal 750GB drive and let it rip, this will map off as many bad sectors and improve reliability.
    Now use Carbon Copy Cloner to clone the 500GB Lion + Lion Recovery Partitions to the internal 750GB, it will "fix" things and place Lion Recovery at the bottom of the drive where it belongs, give all the extra space to OS X Lion.
    Next your going to have to follow WinClones instructions to restore your Bootcamp, likely you will have to recreate the Bootcamp partition first (in Bootcamp) to the size you want and then clone. Likely Winclone may "fix" Windows to recognize it's in a new larger partition now. I don't know you'll have to check as I haven't used it.
    When Bootcamp creates the partition it will place it near the bottom next to the Lion Recovery Partition.
    As you know you will have to re-validate Windows with Lord Redmond or it expires as you changed the hardware.

  • Issue with  OBIEE ROW_NUMBER() OVER (PARTITION BY)

    Hi All,
    I am facing some issue with the ROW_NUMBER() OVER (PARTITION BY function in the query that is being generated. I am currently on version 11.1.1.6. I have 1 FACT and 1 Dimension table. Within the dimension I have create a level based hierarchy namely REGION -> GROUP - DIVISION etc. Now the problem is that the OBIEE automatically applies *"ROW_NUMBER() OVER (PARTITION BY T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.REGION_DESC ORDER BY T9.PRODUCT_TYPE_DESC ASC, T130.DIVISION_DESC ASC, T130.REGION_DESC ASC) "
    to the query where in it is not required at it returns with 3 different row numbers. If i remove this line and the where clause I am able to get correct results however its not working whatever I do in the RPD. Please advise.
    WITH
    SAWITH0 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6
    from
    (select sum(T157.PL_GRAND_TOTAL) as c1,
    sum(T157.TRANSACTION_AMT) as c2,
    T130.DIVISION_DESC as c3,
    T130.REGION_DESC as c4,
    T130.GROUP_DESC as c5,
    T9.PRODUCT_TYPE_DESC as c6,
    ROW_NUMBER() OVER (PARTITION BY T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.REGION_DESC ORDER BY T9.PRODUCT_TYPE_DESC ASC, T130.DIVISION_DESC ASC, T130.REGION_DESC ASC) as c7
    from
    DIM_ALL_MODULES_REF T9,
    DIM_MIS_TREE_REF T130,
    DIM_DATE_SERIES T123,
    FCT_ALL_MODULES_TRANS T157
    where ( T9.SGK_MIS_ID = T130.SGK_MIS_ID and T9.SGK_MODULE_ID = T157.SGK_MODULE_ID and T123.SGK_TIME_ID = T157.SGK_TIME_ID and T123.TRANS_DATE between TO_DATE('2011-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2011-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    group by T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.GROUP_DESC, T130.REGION_DESC
    ) D1
    where ( D1.c7 = 1 ) ),
    SACOMMON42934 AS (select T130.DIVISION_DESC as c2,
    T130.REGION_DESC as c3,
    T130.GROUP_DESC as c4,
    T9.PRODUCT_TYPE_DESC as c5,
    sum(T258.BEG_NMK_EQ_COST_AMT) as c6,
    T123.TRANS_DATE as c7,
    sum(T258.END_NMK_EQ_COST_AMT) as c8
    from
    DIM_ALL_MODULES_REF T9,
    DIM_MIS_TREE_REF T130,
    DIM_DATE_SERIES T123,
    FCT_MODULES_BEG_END_BAL T258
    where ( T123.SGK_TIME_ID = T258.SGK_TIME_ID and T9.SGK_MIS_ID = T130.SGK_MIS_ID and T9.SGK_MODULE_ID = T258.SGK_MODULE_ID and T258.PRODUCT_TYPE_ID = 2 and T123.TRANS_DATE between TO_DATE('2011-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2011-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    group by T9.PRODUCT_TYPE_DESC, T123.TRANS_DATE, T130.DIVISION_DESC, T130.GROUP_DESC, T130.REGION_DESC),

    Hi Dhar,
    Thanks for replying back. But the ROW_NUMBER thing is inserted with the "WITH SUPPORTED" clause only but that is something which are the default settings. However, I notice that ROW_NUMBER() OVER (PARTITION BY) lines are erratic and are not consistent. So sometimes the drill works properly when no ROW_NUMBER() OVER (PARTITION BY) is generated but other times data is wrong. I am not sure why this behaviour is erratic even though I select the same values.
    This is surely a product problem as the condition where c7 = 1 filters the result and does not take into account all values.
    Even when I do not use WITH_SUPPORTED clause the stitch does not happen properly. Please advice if this is ever going to be by Oracle or any work around for this?
    Thanks

  • How can I make multi partitions in my computer with Windows 7??

    How can I make multi partitions in my MakBook with Windows 7??

    From what I read you can't. If you used Boot Camp to partition the Macintosh hard drive so you could install Win 7 on a boot camp partition you are locked into that one partition.
    If you try to RE-partition that BC partition Win 7 won't boot, and IIRC there is a possibility of OS X not booting (Not sure about that). I just went through this myself.
    That's one of the big reason I have gone back to Win PCs as my main systems.
    Mac's are OK but to restrictive in what you can do with the hardware, and the OS IMHO.

  • How  can use a variable in the folowing code?

    How  can use a variable 'W_ROWNUM2' in the folowing code?
    MOVE '1' TO CNT.
    LOOP AT L_T_PM2.
                  CONCATENATE '0' CNT INTO W_ROWNUM2.CONDENSE W_ROWNUM2.
                   CONCATENATE 'F110V-VARI'W_ROWNUM2'(01)' INTO FLD2.
        perform  DYNPRO_FIELD       using FLD2
                                     L_T_PM2-vari12_con.
                   CNT = CNT + 1.
                   CONDENSE CNT.                                                              
    ENDLOOP.
    I need to increment the value of W_ROWNUM2.
    Please ,it is urgent!!

    Hello
    CONCATENATE 'F110V-VARI'W_ROWNUM2'(01)' INTO FLD2.
    Try using spaces between parts of the resulting string.
    CONCATENATE 'F110V-VARI'  W_ROWNUM2  '(01)'   INTO FLD2
    Regards
    Greg Kern.

  • HT1382 How can I copy over my contact list from my ipod touch 3 to my new ipod touch 5 ?

    How can I copy over my contact list from my ipod touch 3 to my new ipod touch 5 ??

    Sync it with iTunes on your computer.

  • How can use linux in my macbook?

    how can use linux in my macbook?

    You can use various distributions of Linux either by running them under Boot Camp, or in a virtualized environment such as Parallels or VMWare's Fusion. Note that you may have to try several different distros until you find one that works. I settled on Ubuntu running under Parallels.
    Best of luck.

  • How can use my songs as my ringtone...???

    How can use my songs as my ringtone...???

    You have to create the ringtones.
    Type "create iphone ringtones" inot the google search bar.  I did and got several links to learn how to make ringtones.

  • How can use my Wireless Location Appliance to work with RF ID's?

    How can use my Wireless Location Appliance to work with RF ID's for Asset Tagging.
    It seems Smartcard used for ID cards have a small RF ID, can I use this for Asset Tagging?
    Thanks in Advance

    There are two kinds of RFID tags: Active tags, which have a battery or other internal power source, and passive tags, which have no power source and work by reflecting the energy from an RFID scanner (basically). At the energy levels and distances used for WiFi location detection, passive tags will not return a detectable signal.
    Take a look at http://www.aeroscout.com/ for more info on WiFi RFID tagging.

Maybe you are looking for