I am new to oracle, plz..anybody can explain this query step by step....plz

Select distinct(a.esal) from employee1 a where &N = (select count(distinct(b.esal)) from employee1 b where a.esal<=b.esal);
this is the query to find Nth largest & Nth smallest value from the table employee1....but, i am unable to understand how this query works ....plz..anybody can explain this query step by step with example....plz

Hi,
Welcome to the forum!
The first step in understanding any code is to format it so you can easily see what is a sub-query, what the major clauses of each sub-query are, and things like that.
For example:
Select distinct (a.esal)
from   employee1      a
where  &N     = (       select  count (distinct (b.esal))
                         from      employee1      b
                where      a.esal           <= b.esal
            );The only thing I have added to the code you posted was whitespace: newlines, tabs and spaces.
Now it's easy to see that you're doing a query with a scalar sub-query in the WHERE clause.
It usually makes sense to read complicated queries from the inside out, that is, start with the deepest nested sub-query.
In this example, that means:
select  count (distinct (b.esal))
from     employee1      b
where     a.esal           <= b.esalWhat does this query do? Unfortunately, it references something (b.esal) from the super-query, so you can't run it by itself, to see what it does. Let's replace that reference with some hard-coded value, just for now, and run it:
select  count (distinct (b.esal))
from     employee1      b
--where     a.esal           <= b.esal     -- This is the original WHERE clause
where   a.esal           <= 1000     -- For testing only
;Experiment with this for a while, and compare it to the values in the employee1 table (or a small test table that resembles employee1). Try different numbers in place of 1000.
You'll see that the query is counting how many different salaries are lower than, or equal to, a given salary (1000 in the example above).
When you understand the sub-query, look at the original query again.
It is testing to see if exactly &N different esals are lower than or equal to the esal on each row, and displaying that esal if it is. (&N is a substitution variable. If you haven't already defined a value for it, SQL*Plus will ask you for a value when you run the query.)
In other words, it is finding the N-th lowest value of esal.

Similar Messages

  • Strange: blank in string. Anybody can explain this?

    Hello!
    Look at this. Until now I thougt, I had understood ABAP...
    Output of the following programm:
    1) Strange
    2) Strange
    3) Strange
    4) Strange
    5) Strange
    6) Strange
    Very strange, isn't it?
    ABAPDOCU tells, that strings pay attention to blanks.
    Can anybody explain this?
    REPORT zstrange.
    DATA: stringwithspace TYPE string VALUE 'A B',
          teststring TYPE string,
          blankstring TYPE string VALUE ' ',
          l type i.
    START-OF-SELECTION.
      IF stringwithspace+1(1) = ' '.
        WRITE: / '1) My guess'.
      ELSE.
        WRITE: / '1) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = blankstring.
        WRITE: / '2) guess'.
      ELSE.
        WRITE: / '2) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = ''.
        WRITE: / '3) guess'.
      ELSE.
        WRITE: / '3) Strange'.
      ENDIF.
      teststring = stringwithspace+1(1).
      IF teststring = ' '.
        WRITE: / '4) Guess'.
      ELSE.
        WRITE: / '4) Strange'.
      ENDIF.
      IF teststring = blankstring.
        WRITE: / '5) Guess'.
      ELSE.
        WRITE: / '5) Strange'.
      ENDIF.
      IF teststring = ''.
        WRITE: / '6) guess'.
      ELSE.
        WRITE: / '6) Strange'.
      ENDIF.

    No, thats not strange.
    c variables have always a fixed length, it can not contain "nothing". If there are only spaces in, the c variable is treated as empty/initial.
    Strings can contain nothing, and they can contain spaces. A string containing blanks is not interpreted as empty/initial.
          blankstring TYPE string VALUE ' ',
    What you are doing here is assigning an empty string to the string var blankstring, it does NOT contain a blank.
    Constants encapsulated with apostrophes are treated as c variables. But: constants encapsulated within back quotes will be interpreted as string. Change your code to
          blankstring TYPE string VALUE ` `,
    Take care of that i used back quotes now, not apostrophes, Now the var blankstring contains a blank and the result in that case will change to MY guess.
    Similar the camparison
      IF stringwithspace+1(1) = ' '.
    This is comparing a blank with an empty char and thats why you are getting strange.
    Change this to
      IF stringwithspace+1(1) = ` `.
    and you will get My guess cause now you are comparing a blank with a blank and not a blank with an empty string.
    Hope its now clear.

  • How I can change this query, so I can display the name and scores in one r

    How I can change this query, so I can add the ID from the table SPRIDEN
    as of now is giving me what I want:
    1,543     A05     24     A01     24     BAC     24     BAE     24     A02     20     BAM     20in one line but I would like to add the id and name that are stored in the table SPRIDEN
    SELECT sortest_pidm,
           max(decode(rn,1,sortest_tesc_code)) tesc_code1,
           max(decode(rn,1,score)) score1,
           max(decode(rn,2,sortest_tesc_code)) tesc_code2,
           max(decode(rn,2,score)) score2,
           max(decode(rn,3,sortest_tesc_code)) tesc_code3,
           max(decode(rn,3,score))  score3,
           max(decode(rn,4,sortest_tesc_code)) tesc_code4,
           max(decode(rn,4,score))  score4,
           max(decode(rn,5,sortest_tesc_code)) tesc_code5,
           max(decode(rn,5,score))  score5,
           max(decode(rn,6,sortest_tesc_code)) tesc_code6,
           max(decode(rn,6,score))  score6        
      FROM (select sortest_pidm,
                   sortest_tesc_code,
                   score,
                  row_number() over (partition by sortest_pidm order by score desc) rn
              FROM (select sortest_pidm,
                           sortest_tesc_code,
                           max(sortest_test_score) score
                      from sortest,SPRIDEN
                      where
                      SPRIDEN_pidm =SORTEST_PIDM
                    AND   sortest_tesc_code in ('A01','BAE','A02','BAM','A05','BAC')
                     and  sortest_pidm is not null 
                    GROUP BY sortest_pidm, sortest_tesc_code))
                    GROUP BY sortest_pidm;
                   

    Hi,
    That depends on whether spriden_pidm is unique, and on what you want for results.
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevamnt columns only) for all tables, and the results you want from that data.
    If you can illustrate your problem using commonly available tables (such as those in the scott or hr schemas) then you don't have to post any sample data; just post the results you want.
    Either way, explain how you get those results from that data.
    Always say which version of Oracle you're using.
    It looks like you're doing something similiar to the following.
    Using the emp and dept tables in the scott schema, produce one row of output per department showing the highest salary in each job, for a given set of jobs:
    DEPTNO DNAME          LOC           JOB_1   SAL_1 JOB_2   SAL_2 JOB_3   SAL_3
        20 RESEARCH       DALLAS        ANALYST  3000 MANAGER  2975 CLERK    1100
        10 ACCOUNTING     NEW YORK      MANAGER  2450 CLERK    1300
        30 SALES          CHICAGO       MANAGER  2850 CLERK     950On each row, the jobs are listed in order by the highest salary.
    This seems to be analagous to what you're doing. The roles played by sortest_pidm, sortest_tesc_code and sortest_test_score in your sortest table are played by deptno, job and sal in the emp table. The roles played by spriden_pidm, id and name in your spriden table are played by deptno, dname and loc in the dept table.
    It sounds like you already have something like the query below, that produces the correct output, except that it does not include the dname and loc columns from the dept table.
    SELECT    deptno
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno
                                              ORDER BY          max_sal     DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno
                       ,           e.job
    GROUP BY  deptno
    ;Since dept.deptno is unique, there will only be one dname and one loc for each deptno, so we can change the query by replacing "deptno" with "deptno, dname, loc" throughout the query (except in the join condition, of course):
    SELECT    deptno, dname, loc                    -- Changed
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno, dname, loc          -- Changed
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno      -- , dname, loc     -- Changed
                                              ORDER BY          max_sal      DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
    GROUP BY  deptno, dname, loc                    -- Changed
    ;Actually, you can keep using just deptno in the analytic PARTITION BY clause. It might be a little more efficient to just use deptno, like I did above, but it won't change the results if you use all 3, if there is only 1 danme and 1 loc per deptno.
    By the way, you don't need so many sub-queries. You're using the inner sub-query to compute the MAX, and the outer sub-query to compute rn. Analytic functions are computed after aggregate fucntions, so you can do both in the same sub-query like this:
    SELECT    deptno, dname, loc
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
                   SELECT    e.deptno, d.dname, d.loc
              ,       e.job
              ,       MAX (e.sal)     AS max_sal
              ,       ROW_NUMBER () OVER ( PARTITION BY  e.deptno
                                           ORDER BY       MAX (sal)     DESC
                                          )       AS rn
              FROM      scott.emp    e
              ,       scott.dept   d
              WHERE     e.deptno        = d.deptno
              AND       e.job                IN ('ANALYST', 'CLERK', 'MANAGER')
                  GROUP BY  e.deptno, d.dname, d.loc
              ,       e.job
    GROUP BY  deptno, dname, loc
    ;This will work in Oracle 8.1 and up. In Oracle 11, however, it's better to use the SELECT ... PIVOT feature.

  • Can anyone explain this query.?

    Can anyone explain this query.?
    select nvl(s.p_id,q.p_id),nvl(s.p_type,q.p_type),nvl(s.p_line,q.p_line),
    nvl(s.sales2004,0),nvl(s.sales2005,0),nvl(q.quota2004,0),nvl(q.quota2005,0)
    from sales s
    full outer join quota q on(s.p_id = q.p_id and s.p_type=q.p_type and s.p_line=q.p_line)

    from sales s full outer join quota qTable quota is outer joined to table sales , if there are no matching records in table quota then also the query retuns the sales record with null values for the corresponding quota record columns
    NVL() has been used to handle such cases

  • How I can change this query

    How I can change this query, I got it from someone on the list, and it works just fine, Thank you! but I can not hardcode the data, the data is actually in a repiting table
    SARAPPD_PIDM, SARAPPD_TERM_CODE_ENTRY, SARAPPD_APPL_NO 1 SARAPPD_SEQ_NO
    We can have a person with one record another one with two or three, we just don't know, each record have a sequence number SARAPPD_SEQ_NO
    this SARAPPD_PIDM = 2232040 with will a paramater pass to the function (SARAPPD_PIDM = p_pidm)
    excuse my ignorance, but I just don't have experience with this kind of queries..
    with t as ( -- sample data
        select 2232040     SARAPPD_PIDM,  200990 SARAPPD_TERM_CODE_ENTRY, 1 SARAPPD_APPL_NO, 1 SARAPPD_SEQ_NO,   to_date('12/03/2008','mm/dd/yyyy') sARAPPD_APDC_DATE,  'S*'     SARAPPD_APDC_CODE from dual union all
        select 2232040     ,200990     ,1    ,2     ,to_date('12/08/2008','mm/dd/yyyy'),     'D1' from dual union all
        select 2232040     ,200990     ,1    ,3    ,to_date('03/18/2009','mm/dd/yyyy'),  'S*'  from dual union all
        select 2232040    ,200990     ,1    ,4     ,to_date('03/29/2009','mm/dd/yyyy')     ,'WL' from dual union all
        select 2232040    ,200990     ,1    ,4     ,to_date('03/27/2009','mm/dd/yyyy')     ,'WL' from dual
        ) -- end sample data
        SELECT * FROM (
        SELECT
       A.SARAPPD_PIDM,
       A.SARAPPD_APDC_CODE,
       A.sarappd_apdc_date,
       ROW_NUMBER() OVER (PARTITION BY SARAPPD_PIDM, SARAPPD_TERM_CODE_ENTRY ORDER BY SARAPPD_APDC_DATE
       DESC) row_num
       ,lead (SARAPPD_APDC_DATE,1) over (ORDER BY SARAPPD_APDC_DATE) AS next_date
       FROM t A
       where
        SARAPPD_PIDM = 2232040
         AND sarappd_apdc_code IN ('SA', 'FA', 'S-', 'F-', 'RF', 'F*','AD', 'W-', 'R2', 'S*', 'HF', 'WL','HD', 'R1', 'HS', 'D2', 'W+')
       where  next_date >= to_date('3/27/2009','mm/dd/yyyy');Edited by: user648177 on May 1, 2009 8:52 AM

    Thank you
    I am getting this result
    SARAPPD_PIDM     SARAPPD_APDC_CODE              SARAPPD_APDC_DATE     SARADAP_ADMT_CODE     ROW_NUM               NEXT_DATE
    2232040                                   S*            12/03/2008 16:30:45     D1                                    3                  03/18/2009 08:58:06
    2232040                                   S*            03/18/2009 08:58:06     D1                                      2                 03/21/2009 13:53:23I only want to retrieve the one with the max date ( 03/18/2009 08:58:06)
    I try to add the
    and SARAPPD_SEQ_NO = (select max(b.SARAPPD_SEQ_NO)
                                   from SARAPPD b
                                   where SARAPPD_pidm = b.SARAPPD_pidm)
    {code}
    {code}
    but it did not work
    {code}
    SELECT *
      FROM (SELECT A.SARAPPD_PIDM,
                   A.SARAPPD_APDC_CODE,
                   A.sarappd_apdc_date,
                   saradap_admt_code,
                   ROW_NUMBER() OVER(PARTITION BY SARAPPD_PIDM, SARAPPD_TERM_CODE_ENTRY ORDER BY SARAPPD_APDC_DATE DESC) row_num,
                   lead(SARAPPD_APDC_DATE, 1) over(ORDER BY SARAPPD_APDC_DATE) AS next_date
              FROM saturn.sarappd A, SARADAP
             where SARAPPD_PIDM = 2232040
               and SARADAP_PIDM = SARAPPD_PIDM
               AND saradap_term_code_entry = SARAPPD_TERM_CODE_ENTRY
               AND SARADAP_APPL_NO = A.SARAPPD_APPL_NO
               --         and SARAPPD_SEQ_NO = (select max(b.SARAPPD_SEQ_NO)
                --                    from SARAPPD b
                --                    where SARAPPD_pidm = b.SARAPPD_pidm)
               AND sarappd_apdc_code IN
                   ('SA', 'FA', 'S-', 'F-', 'RF', 'F*', 'AD', 'W-', 'R2', 'S*', 'HF', 'WL', 'HD', 'R1', 'HS', 'D2', 'W+'))
    Where next_date <=       saturn_midd.utlq.f_get_adm_freeze_date(saradap_admt_code)
    {code}
    i now that if I add and row_num=2 it will work, but this is just an example I don't know the row_num of all the records
    Edited by: user648177 on May 4, 2009 5:57 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Anybody can make this simple custom component a complied clip!!!?

    Hi,
    I have a custom component that has this line of code in the
    first frame:
    trace(this.Num1 + this.Num2);
    where:
    Num1:is a Number parameter created via component definition
    window
    Num2:is a Number parameter created via component definition
    window
    when I convert this component to a compiled clip it dose not
    work because the parameters disappear from the parameter panel and
    the component inspector parameters.
    I have this trace"
    NaN
    anybody can make it work!!!!
    thanks a lot.

    hello, here is another thread with similar issue and the op seems to have it kinda working
    http://forums.adobe.com/thread/1141054
    post 14
    re: the chipmunk audio, i think in the speed rate setting there is a check box to preserve audio pitch (i'm not sure exactly)
    the time remapping feature might work because it does not affect the audio
    here is a creative cow forum thread where the op says it works (perhaps you could post there and get him to give advice)
    http://forums.creativecow.net/thread/3/935431
    the more information you provide the more users can help you
    here is another thread re: gopro3
    http://forums.adobe.com/thread/1116162
    here is a link to converting files if you have a mac
    http://www.brorsoft.com/how-to/import-gopro-hero3-1080-60p-mp4-to-premiere-pro-cs6.html
    here is one from the gopro forum
    http://goprouser.freeforums.org/wvga-120-fps-adobe-premiere-settings-t8315.html

  • Plz help me design this query

    Hi,
    Can you’ll please help me with this query.
    Here is a little bit of background:
    One title can have multiple items associated with it.
    Table: TITLE has the master list of titles. TITLE_ID is the primary key.
    Table: ITEM has the master list of all items. ITEM_ID is the primary. This table also has the TITLE_ID which stores title for this item.
    Table: ITEM_STATUS has fields ITEM_ID and STATUS_ID. This field contains statuses for items. But not all items contained in the table ITEM are in this table.
    I want to find TITLE_ID’s whose all items (all ITEM_ID in table ITEM having same value for TITLE_ID) have a particular status (for example STATUS_ID = 2) in table ITEM_STATUS.
    Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and only 4 items out of it in table ITEM_STATUS with STATUS_ID = 2, then this TITLE_ID should not come. OR
    Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and all these 5 items are in table ITEM_STATUS but only 1 has STATUS_ID = 2, then this TITLE_ID should also not come
    In the above case only if all 5 items are contained in table ITEM_STATUS have STATUS_ID = 2 then this TITLE_ID should be reported by the query.
    What should be the query like for this one, I am fairly new to SQL so plz guide me.
    Thank you,
    Raja

    I haven't tested the query below. Try it and let me know for any issues:
    SELECT     DISTINCT t.title_id
         FROM     title t,
                        item i,
                        item_status its
    WHERE     t.title_id = i.title_id
         AND     i.item_id = its.item_id
         AND     NOT EXISTS     (
                                                           SELECT 1
                                                                FROM item_status its1
                                                           WHERE its1.item_id = i.item_id
                                                                AND status_id <> 'YOUR_ITEM_STATUS'
                                                      )

  • Accent insensitive Search - plz help me correcting this query

    Hello,
    I just realized that with that query, if I search for "Montreal" (without the accent), I have all the following results, which is what I want
    SELECT
    "ID","TIT"
    from   "REGDOSSIERS" "RDO"
           where
             TRANSLATE(UPPER("TIT"),'ÀÂÉÈÊÎÔÛÙÜ','AAEEEIOUUU')
             like upper(nvl(replace('%' || "P1_REPORT_SEARCH || '%',' ','%'),"TIT"))
    RESULTS
    TIT
    Annuaires Lovell (Montréal et banlieue)
    Juridiction royale de Montréal. Dossiers, 1677-1769
    Montreal Witness, 1845-1938
    {code}
    But how to change it so when I look for: "Montréal" (with the accent) , I have also the same results? Right now, with Montréal, I have nothing
    thanks,
    Roseline
    Edited by: Roseline on 2009-10-01 18:58
    Edited by: Roseline on Oct 1, 2009 7:34 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    If you are on Oracle 10g you can use regexp expressions to do the search.
    Example
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where regexp_like (txt, 'Montr[[=e=]]al');
    txt
    Montreal
    Montréal[[=e=]] would be an equivalence class for the letter "e" and includes also searches for é, è, ê etc.
    The best solution mainly depends how your search string is build.
    If you just want to sort, then the nlssort function would be useful.
    Mentioning Nlssort I remembered there is a much better way to implement Accent insensitive search. You just need to set your NLS_SORT parameter correctly. Either to BINARY_AI (the AI means accent and case insensitiv) or add _AI to your nls langage.
    example
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    alter session set nls_sort = 'FRENCH';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    no rows selects
    /* now change the nls sorting */
    alter session set nls_sort = 'FRENCH_AI';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    txt
    Montreal
    Montréal
    MontreâlEdited by: Sven W. on Oct 2, 2009 8:34 AM
    Edited by: Sven W. on Oct 2, 2009 10:22 AM - corrected misleading regexp example.

  • How I can change this query to generate a sequence

    This query
    select
    SZSTCLA_PIDM,
      SZSTCLA_TERM_CODE,
      SZSTCLA_LAST_NAME
      from SZSTCLA,SHRTGPA
    where SZSTCLA_PIDM IN ( 120125,186114)
    AND SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODE
    AND  shrtgpa_pidm  = SZSTCLA_PIDM
      AND SZSTCLA_RECORDED_EARNED_CRED > 0
      ORDER BY SZSTCLA_TERM_CODE returns the following results
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME
    186114     198810     Johnson
    186114     198820     Johnson
    186114     198910     Johnson
    186114     198920     Johnson
    186114     199010     Johnson
    186114     199020     Johnson
    186114     199110     Johnson
    186114     199120     Johnson
    120125     200720     Smith
    120125     200810     Smith
    120125     200820     Smith
    120125     200910     Smith
    120125     200920     Smith
    120125     201010     Smith
    120125     201020     Smith
    120125     201110     Smith
    120125     201120     SmithNotice that breaks in every szstcla_pidm, I need to modify the query, so it can display a number sequence for each SZSTCLA_TERM_CODE
    so it will be like
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME                                    seq
    186114                     198810                                     Johnson                         1
    186114                     198820                                     Johnson                         2
    186114                    198910                                     Johnson                         3
    186114                    198920                                     Johnson                         4
    186114                    199010                                     Johnson                         5
    186114                    199020                                     Johnson                         6
    186114                    199110                                     Johnson                         7
    186114                    199120                                     Johnson                         8 then
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME                                      seq
    120125                  200720                                   Smith                             1
    120125                  200810                                    Smith                             2
    120125                  200820                                   Smith                              3
    120125                  200910                                   Smith                              4
    120125                  200920                                   Smith                              5
    120125                  201010                                   Smith                              6
    120125                  201020                                   Smith                              7
    120125                  201110                                   Smith                              8
    120125                  201120                                   Smith                              9

    here are the insert scripts,I slighthly change the name of the tables(the tables are already in the DB)
    create table SZSTCLT
    SZSTCLT_PIDM NUMBER(8),
    SZSTCLT_TERM_CODE VARCHAR2(8),
    SZSTCLT_LAST_NAME VARCHAR2(30)
    create table SHRTGPT
    SHRTGPT_PIDM NUMBER(8),
    SHRTGPT_TERM_CODE VARCHAR2(8)
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198810','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198820','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198910','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198920','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199010','Johnson' FROM DUAL; 
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199020','Johnson' FROM DUAL;  
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199110','Johnson' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199120','Johnson' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'200920','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201010','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201020','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201110','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201120','Smith' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '200920' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201010' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201020' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201110' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201120' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198810' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198820' FROM DUAL;  
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198910' FROM DUAL;    
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198920' FROM DUAL;    
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199010' FROM DUAL;  
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199020' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199110' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199120' FROM DUAL;   This query
    select
    SZSTCLT_PIDM,
      SZSTCLT_TERM_CODE,
      SZSTCLT_LAST_NAME,
      row_number() over (partition by  SZSTCLT_PIDM, SZSTCLT_TERM_CODE order by  SZSTCLT_PIDM,SZSTCLT_TERM_CODE)   seq
      from SZSTCLT,SHRTGPT
    where SZSTCLT_PIDM IN ( 120125,186114)
    AND SHRTGPT_TERM_CODE = SZSTCLT_TERM_CODE
    AND  SHRTGPT_PIDM  = SZSTCLT_PIDM
    -- AND SZSTCLA_RECORDED_EARNED_CRED > 0
    ORDER BY SZSTCLT_PIDM,SZSTCLT_TERM_CODE is generating this output
    120125     201020     Smith     1
    120125     201110     Smith     1
    120125     201120     Smith     1
    186114     198810     Johnson     1
    186114     198820     Johnson     1
    186114     198910     Johnson     1
    186114     198920     Johnson     1
    186114     199010     Johnson     1
    186114     199020     Johnson     1
    186114     199110     Johnson     1
    186114     199120     Johnson     1 I want something like this
    120125     201020     Smith     1
    120125     201110     Smith     2
    120125     201120     Smith     3
    186114     198810     Johnson     1
    186114     198820     Johnson     2
    186114     198910     Johnson     3
    186114     198920     Johnson     4
    186114     199010     Johnson     5
    186114     199020     Johnson     6
    186114     199110     Johnson     7
    186114     199120     Johnson     8 Edited by: 893973 on Sep 15, 2012 6:52 PM

  • Question on me51n: who can explain this phenomenon?

    Hi all,
    I am creating a Purchase Requisition via me51n.
    When I fill a 'K' or 'P' in the "acct assignment cat."(A) column in the Header Block. it will automatically bring me to the "Account Assignment" in the Item block, and give the "G/L account no" a default value 400000.
    I dont know why it give me the default value? can someone explain this to me, and where can I set up the configuration for the default value. I tried this in some other system, no such issues.
    Any response will be awarded.
    Thanks and regards,
    Samson

    hi,
    this is because an account modification key is maintained in your account assignemnet.
    please check the same in(OME9)
    say for example if VBR is maintained there check the sane in OBYC where correspondent to that account modification key same GL is maintained which it appears in your PR/PO
    VBR will be there in GBB Transaction key in OBYC
    Edited by: manipal on Dec 28, 2007 9:49 AM

  • How I can change this query? to get the results I want

    This query
    select
    SHRTGPA_pidm,
    SZSTCLA_TERM_CODE,
    SHRTGPA_GPA_HOURS
    from  szstcla,SHRTGPA
    where szstcla_pidm = 74246
    and SHRTGPA_pidm = szstcla_pidm
    and SZSTCLA_TERM_CODE <> SZSTCLA_TERM_CODE_MATRIC
    and SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODEreturns
    74246     201020     4
    74246     201120     4
    74246     201110     4
    74246     201210     4
    74246     201220     4 I want to aggregate so the query will return
    74246 201020     4
    74246 201120     8
    74246 201110     12
    74246 201210     16201220     20

    Hi,
    So, instead of shrtgpa_gpa_hours, you want a cumulative total of shrtgpa_gpa_hours, adding up all the previous values.
    That's a job for the analytic SUM function:
    select
    SHRTGPA_pidm,
    SZSTCLA_TERM_CODE,
    SUM (SHRTGPA_GPA_HOURS) OVER (ORDER BY x)  as running_shrtgpa_gpa_hours     -- *****  CHANGED  *****
    from  szstcla,SHRTGPA
    where szstcla_pidm = 74246
    and SHRTGPA_pidm = szstcla_pidm
    and SZSTCLA_TERM_CODE  SZSTCLA_TERM_CODE_MATRIC
    and SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODEwhere x is the expression (or list of expressions) that determines what are the "previous" rows.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • I am a new egyption oracle user and i need some help....plz

    plz when i mack 2 windows in the developer i can exit the form but can't exit any window ..
    for example :- i macked 2 blocks and but each block in difrent window the 1st window called (zz) and the 2nd called (ww) now i can exit the form at all but can't exit (zz) or (ww) alone ..........
    plz help me thanks
    a.sherif

    You sound like you are using Oracle developer tools - the forums you need are on technet.oracle.com
    I am sure that if you post the query there you will get a response on a developers forum

  • Can't get the "send" button to activate in the Messages application on a new 4th gen iPad. anybody else have this problem?

    Ipad works properly receiving messages but the applicationAnybody else seen this problem and have it solved?

    this happend on my ipad as well, make sure the person you are tryng to send an imessage to is registered with imessage. if you tap on the number itself, if it shows up in red it should say this phone number is not registered with imessage.
    if thats the case.

  • HT1222 My iPhone 5 keeps saying I don't have enough storage to update software even though I just purchased 15GB of storage. Can anybody please explain this to me? I'm really not tech savvy AT ALL so I don't have a clue what to do :(

    My iPhone keeps telling me I don't have enough space to update my software. But I just bought 15GB of storage, of which 11.7GB is free! So I don't understand. Can anybody please help me? I'm really bad with technology so I don't have a clue.

    Hi Caroline,
    The storage issue you are having is not related to iCloud. The error is telling you that you do not have enough room on your device itself. You need to go to Settings>General>Usage, and under the Storage section at the top, it lists all of your apps and other things taking up room on your device.
    You will have to delete or reduce the size of items on this list in order to free up some room for your update.
    Also, you may want to try the update by hooking up your device to iTunes on the computer you sync with. It does not require as much free memory to update via iTunes as it does OTA.
    Cheers,
    GB

  • Palm Vx meets Windows 7 64 Bit - I want to HotSync my old Palm Vx's with my new desktop PC. Anybody know whether this will work out?

    I have 2 old but beautiful Palm Vx's that still serve me well. I have a new Windows 7 - 64 bit desktop PC and cannot get them to HotSync. The new desktop has no COM3 port and the serial to USB adapter cable I have doesn't help. Does anyone have any ideas how to help this May/December relationship work out?
    Post relates to: Palm Vx

    UPDATE: My problem seems to have disappeared!  I am mystified.
            Fearing I might lose all important Vx data, I switched to an old XP desktop (32bit) and installed Palm Desktop/USB to RS232 adaptor. After some fiddling with port settings all went well and was relieved to make a backup on the old machine.
            This morning, returned to the new machine (Sony VAIO with Windows 7 Premium (64bit) and ABC Products adaptor (uses Prolific driver) in a more relaxed state of mind. Powered-up tried a hotsync; then started Palm Desktop and all was there and visible.
            I can only suggest that the full 'power-down and restart' overnight must have performed a necessary re-initialisation.
           I now subscribe to those indicating that Palm Desktop 4.1.4 can work with Windows 7 (64bit). Note that Windows 7 Premium does not support XP emulation.
           I hope my report will encourage others who wish to hang on to old Palm PDAs.
    ======================================================================
    I note many others have trodden this path and it still seems that Palm, or latest acquirer, wants to keep out of it!
    My XP laptop just recently died and I now have a Windows 7 replacement with no RS232 port. I have been trying to get linked up via the USB port, using an adaptor, so that I can have a backup for much valuable info on my trusty Palm Vx.
    It is very frustrating; almost works but not the final step. I can see the files have transferred from Vx to Palm Desktop 4.1.4. (using MS Notepad) but when I view using Desktop, it does not "see" them. The Notepad view reveals "padding" characters in the files. I am confident that this cannot be attributed to the USB/RS232 adaptor or related software; I believe it to be the Desktop software.
    Would Desktop 6.2 be a viable approach to try with a Vx? Are there any third-party patches for 4.1.4 to overcome the transfer problem. I am perplexed to see that others seem to have made it work on 64 bits.
    COMMENTS/SOLUTIONS WILL BE MUCH APPRECIATED

Maybe you are looking for

  • Creation of file using URI

    I am working on jsp I want to create a file object with path "http://localhost:8080/examples/" so i have tried to create file with URI as parameter but i'm not able to succed. so please do help me. thanks in advance. actual situation is any remote cl

  • Creating a CLOB in jdbc

    I have a PL/SQL stored procedure which accepts a CLOB data type as one of the arguments. This procedure inserts a record into a table which has a column of datatype CLOB. Using jdbc, my java program creates a CallableStatement to the stored proc. Now

  • Basis Parameters for CRM

    Hi, are there any performance related / recommended parameters for CRM 4 systems? Can't find a specific note from SAP like is the case with BW and R/3. Many thanks, AB

  • Windows will not install under Mavericks

    I am trying to install W7, again, under Mavericks and I cannot do so. Every thing seem to be installed but at start, I get a message that "BOOTMGR is missing, press ctl+alt+delete to restart", but the keyboard (wired and working) will not function so

  • "Saving to Aol" email

    Is it something that I am missing or is it not possible to save your emails to your aol server storage using Mac Aol software. I had enough problems getting the UK Aol software running on my wife's MacBook Pro that I've ended up using the US client s