Dense_rank() question

My question when is best to use dense_rank(). Looking for an example.

As opposed to what?
If we're going to compare something, we need something to compare it to. For example, are you asking us when you would use dense_rank rather than similar alanytic functions like rank and row_number? Are you asking when you would use analytic functions in the first place? Or are you asking something else?
Justin

Similar Messages

  • Simple Dense_rank Question

    Hi,
    Where am I going wrong here..
    SELECT AAFRM_ID, AGENCY_AGY_CODE,
    DENSE RANK() OVER( PARTITION BY AGENCY_AGY_CODE
    ORDER BY AAFRM_ID ASC NULLS LAST) DENSE_RANK
    FROM agency_application_form
    WHERE AGENCY_AGY_CODE IN (6412,7911);and I am getting this error:
    Error report:
    SQL Error: ORA-00923: FROM keyword not found where expected
    00923. 00000 -  "FROM keyword not found where expected"
    *Cause:   
    *Action:Thanks

    You missed the underscore DENSE_RANK:
    With agency_application_form as
      (select 6412 AGENCY_AGY_CODE, 1 AAFRM_ID from dual union all
       select 6412 AGENCY_AGY_CODE, 2 AAFRM_ID from dual union all
       select 7911 AGENCY_AGY_CODE, 1 AAFRM_ID from dual union all
       select 7911 AGENCY_AGY_CODE, 1 AAFRM_ID from dual)
    SELECT AAFRM_ID,
           AGENCY_AGY_CODE,
           DENSE_RANK() OVER(PARTITION BY AGENCY_AGY_CODE ORDER BY AAFRM_ID ASC ) DENSE_RANK
      FROM agency_application_form
    WHERE AGENCY_AGY_CODE IN (6412, 7911);

  • Lpad use with dense_rank question

    Hi, I looked up lpad/rpad in the 10g Complete refernce but can't seem to figure if I can use it in conjunction with dense_rank.
    When I run "DENSE_RANK () OVER (PARTITION BY 'batch_doc_total' ORDER BY ae.emp_code) AS "batch_skey"," I get numbers starting with 1 however i want it to start with 0001. I have tried about 50 different ways of using the lpad but have had no succes in this case. Can anyone offer a suggestion or does anyone know if there is a limitation with using the 2 functions together?
    Cheers, Peter

    SQL> select empno,lpad(dense_rank() over(order by sal),5,'0') rnk
      2  from emp;
         EMPNO RNK
          7369 00001
          7900 00002
          7876 00003
          7521 00004
          7654 00004
          7934 00005                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • SQL Query Question

    Hi,
    I am trying to filter my output from the query based on some conditions but not able to figure out how. May be I am just overlooking at the issue or is it something tricky.
    So, I have a query returning 4 rows of output out of which I need to filter the rows. I have created a table from the result of the query that I need to filter to make it simple. So below is my create table script and values that are obtained from my original query.
    CREATE TABLE TEMPACCT
      SOURCEKEY           NUMBER,
      FLAG                VARCHAR2(1),
      ITEMID              NUMBER(9)                 ,
      ITEMNAME            VARCHAR2(10)               ,
      ITEMKEY             NUMBER(9)                
    Insert into tempacct values (0, 'N', 100, 'ITEM1' , 9647);
    Insert into tempacct values (0, 'N', 200, 'ITEM2' , 9648);
    Insert into tempacct values (9648, 'N', 100, 'ITEM3' , 9813);
    Insert into tempacct values (9647, 'Y', 100, 'ITEM4' , 9812);
    SQL> select * from tempacct;
    SOURCEKEY F     ITEMID ITEMNAME      ITEMKEY
             0 N        100 ITEM1            9647
             0 N        200 ITEM2            9648
          9648 N        100 ITEM3            9813
          9647 Y        100 ITEM4            9812
    SQL> Tempacct table is the table created from the resultset of my original query.
    So from the above output, what I need is 3 rows. The logic to filter out the row is - If any of the row thathas sourcekey that is same as Itemkey in any of the 4 rows and flag is Y then remove the row which have flag =N and only display the one with Falg = Y.
    Ok, so, in this case the desired output would be
    SOURCEKEY F     ITEMID ITEMNAME      ITEMKEY
             0 N        200 ITEM2            9648
          9648 N        100 ITEM3            9813
          9647 Y        100 ITEM4            9812So here we compared between the first row and the fourth row, and since the sourcekey in fourth row is same as itemkey in first row and Flag is 'Y' for fourth row, we keep 4th row and remove the first row since the flag is 'N'. (and sourcekey is 0. the row that gets removed will always have sourcekey =0) .
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionAppreciate your help.

    Hi,
    ARIZ wrote:
    Although the original question is already been answered, I had another small modification to the same question and also seeking some clarification. I do not want to open a new thread just for a similar question.I think you'll get better replies faster if you do start a new thread.
    Not counting this one, there have been 13 replies to this thread. Not many people who havn't already been participating in this thread are going to start reading a thread with 13 replies. Those who do are going to waste a lot of time reading about issues that have already been resolved, and the are likely to understand the remaining issues incorrectly.
    I have been following the thread from the beginnning, and I'm starting to get confused about what the unresolved issues are.
    I believe there are two things you still need:
    (1) An explanation of the solution I posted yesterday, involving the analytic COUNT function.
    (2) A solution for a new problem involving the same tables
    If I got that wrong, start a new thread, asking just what you need to know. Copy any relevant parts (like the CREATE TABLE and INSERT statements) from this thread. You can include a link to this thread, but do your best to make sure people don't have to use it.
    I realize that's more work for you, but getting the best results, and getting them quickly, sometimes does require more work.
    <h2>(1) An explanation of the solution I posted yesterday, involving the analytic COUNT function.</h2>
    ARIZ wrote:
    Hi Frank,
    Just out of curiosity, I was trying to understand the Count analytical function that you have used in the solution.
                    COUNT ( CASE
                                 WHEN  ac.flag = 'Y'
                           THEN  1
                             END
                        ) OVER ( PARTITION BY  CASE
                                                   WHEN  sourcekey = 0
                                       THEN  acctkey
                                       ELSE  sourcekey
                                               END
                                  )     AS y_cntSo what I am thinking is, this would first partition the row with acctkey ( where sourcekey =0) and sourcekey and then within that partition, it will check whether ac.flag = Y or not, if it is 'Y' then it would return count as 1 else 0. Am I correct? In the mean time I am also reading the tutorials on Count() analytical query. I'm not sure I understand your explanation.
    This is not partitioning first by x, and then by y. There is only one expression in the PARTITION BY clause. Most often, a PARTITION BY clause refers to some column in the table, for example:
    SELECT  ename
    ,       job
    ,       sal
    ,       AVG (sal) OVER (PARTITION BY job)  AS avg_sal_for_job
    FROM    scott.emp;This divides the result set into mutually exclusive parts; there will be as many such parts as there are distinct values for the PARTITION BY column. In the simple query above, if there happen to be 5 different values for job, you will get 5 independent averages.
    In your problem, there is no one column that defines a partition. That is, these two rows belong to the same partition:
    . SOURCEKEY F   ACCTKEY
             0 N       9647
          9647 Y       9812even though none of the 3 columns are the same. We could create a view that had a single column, telling to which partition each row belonged, like this:
    . SOURCEKEY F   ACCTKEY PART_NUM
             0 N       9648     9648
             0 N       9647         9647
          9648 N       9813         9648
          9647 Y       9812         9647where part_num is the result of a CASE expression:
    CASE
        WHEN  sourcekey = 0
        THEN  acctkey
        ELSE  sourcekey
    ENDWe could then use that new column, part_num, in a (very simple) PARTITION BY clause. But there is no need to create a view, even an in-line view, for that: we can (and I did) use the CASE expression directly in a (not so simple) PARTITION BY clause.
    Why did I use COUNT? The important thing about each partition is whether or not it includes any rows with flag='Y'. I don;t know of any function that directly answers that question. There are lots of ways to get the correct answer, but I think the one that corresponds most closely to the question we really want to ask:
    "Do any rows have flag='Y'?" is
    "How many rows have flag='Y'?"
    The analytic function COUNT (x) returns a number (possibly 0) of rows in the partition where x is not NULL. So, as the argument to COUNT, I used
    CASE
        WHEN  ac.flag = 'Y'
        THEN  1
    --  ELSE  NULL          -- I did not explicitly say this, but it is the default
    ENDwhich returns either
    (a) the literal number 1 or
    (b) NULL
    Instead of the literanl number 1, I could have used any literal or expression, of any data type, that is not NULL). all that matters is we produce something non-NULL for COUNT to count.
    <h2>(2) A solution for a new problem involving the same tables</h2>
    Also, I was trying to modify this query to fit my other similar requirement where I would need following output
    Original output:
    SOURCEKEY F    ACCTKEY
    0 N       9648
    0   N      9647
    9648 N       9813
    9647 Y       9812
    So, the query should be smart enough to return only the last two rows where sourcekey >0 which is
    SOURCEKEY F    ACCTKEY
    9648 N       9813
    9647 Y       9812
    And In case there are only first two 2 rows in the table then , it should return only those two row and not check for sourcekey > 0 which would be .
    SOURCEKEY F    ACCTKEY
    0 N       9648
    0   N      9647 Is it something that I should be using analytical function to solve this requirement. I am trying to accomplish this new requirement.If I understand this problem correctly, it does indeed involve mutually exclusive divisions, but in this problem, the divisions correspond more closely to a single column in the table. We want to divide the table into two mutually exclusive groups:
    (A) rows where soucekey > 0, and
    (B) rows where sourcekey = 0
    We could do that with a CASE expression, but there happens to be a built-in function that works very nicely.
    SIGN (sourcekey) returns
    (A) 1 if sourcekey > 0, and
    (B) 0 if sourcekey = 0
    But what do we want to do with those divisions? We want to display rows only from the "best" of those divisions, where division (A) is coinsidered "better" than division (B). That is, if there are any rows in division (A), then we want to display only rows in division (A), but if there are no rows in division (A), then (and only then) we want to display rows in divison (B).
    This is an example of a Top-N Query , where we want to display N items from the top of an ordered list. A typical top-N query uses an analytic function (either ROW_NUMBER, RANK or DENSE_RANK, depending on how we want to handle ties) to assign numbers to each row (lower numbers for the "better" rows), and then uses "WHERE f <= n" to display only the n "best" ones. (A special case, though a very common one, is where N=1, that is, we're only interested in the row (or rows, if there happens to be a tie) with the "best" value. In this case, most people find it cleare to say "WHERE f = 1" ratehr than "WHERE f <= 1". Your problem is an exmple ot that special case.)
    SELECT  sourcekey
    ,     flag
    ,     acctkey
    FROM     (
             SELECT  ac.sourcekey
             ,         NVL (ac.flag, 'N')     AS flag
             ,         ac.acctkey
             ,         DENSE_RANK () OVER (ORDER BY  SIGN (sourcekey)     DESC)     AS division_num
                FROM    itemtable     i
             ,         finance     f
             ,         acct     ac
               WHERE   i.itemtableid1      = f.parentid1
               AND         i.itemtableid2      = f.parentid2
             AND         f.financekey      = ac.financekey
               AND         i.parenttableid      = 19063
    WHERE     division_num     = 1
    ;Notice I talked about "mutually exclusiive *divisions* " above, not "mutually exclusive *partitions* ".
    There is no PARTITION BY in the analytic clause above. PARTITION BY means we want a separate, independent caluclation for each partition. Here, we want one single numbering for the entire result set.
    We want all rows that tie for the "best" to be numbered 1, so we have to use DENSE_RANK (or RANK) rather than ROW_NUMBER.

  • Question about De-Factoring a query

    Good afternoon,
    I have the following query that produces the results I want (it does a DENSE_RANK):
    with agelist as
       select age
         from student
        group by age
    select age,
            select count(*)
              from agelist x
             where x.age <= agelist.age
           )                                as rankedage
      from agelist
    order by rankedage
    ;As an exercise (I'm learning SQL), I wanted to write the equivalent query without using the WITH clause (and without using DENSE_RANK either - in other words, keeping it plain vanilla SQL). Everything I've tried either gives wrong results or a syntax error <chuckle>.
    the question is: What does the working query ;) look like without the WITH (effectively defactoring the "agelist" query ?
    Thank you for your help,
    John.
    DDL to run the query I posted:
      /* table of students */
         create table student
         ( sno integer,
           sname varchar(10),
           age integer
            insert into student values (1,'AARON',20);
            insert into student values (2,'CHUCK',21);
            insert into student values (3,'DOUG',20);
            insert into student values (4,'MAGGIE',19);
            insert into student values (5,'STEVE',22);
            insert into student values (6,'JING',18);
            insert into student values (7,'BRIAN',21);
            insert into student values (8,'KAY',20);
            insert into student values (9,'GILLIAN',20);
            insert into student values (10,'CHAD',21);Edited by: 440bx - 11gR2 on Jul 30, 2010 3:13 PM corrected misspelling in defactoring

    Sorry, but I'm not quite sure what you're trying to do.
    Your WITH clause returns a distinct list of ages. So any ranking can only be a dense_rank since you'll never have a tie. The rownum solution posted by Clearance will accomplish the same thing.
    The whole point of RANK vs DENSE_RANK is how to number the results in the event of equal numbers in the list. Using a distinct or group by kind of defeats the purpose.
    If you comment out the GROUP BY in WITH clause, you get this:
    SQL> with agelist as
      2    (
      3     select age
      4       from student
      5      --group by age
      6    )
      7  select age,
      8         (
      9          select count(*)
    10            from agelist x
    11           where x.age <= agelist.age
    12         )                                as rankedage
    13    from agelist
    14   order by rankedage
    15  ;
                     AGE            RANKEDAGE
                      18                    1
                      19                    2
                      20                    6
                      20                    6
                      20                    6
                      20                    6
                      21                    9
                      21                    9
                      21                    9
                      22                   10That's not a dense rank or even a regular rank. Ages that have duplicates are assigned the lowest ranking in their group.
    Using the RANK analytic function, you get this:
    SQL> select age
      2        ,rank() over (order by age) r
      3  from   student;
                     AGE                    R
                      18                    1
                      19                    2
                      20                    3
                      20                    3
                      20                    3
                      20                    3
                      21                    7
                      21                    7
                      21                    7
                      22                   10And using DENSE_RANK you get this:
    SQL> select age
      2        ,dense_rank() over (order by age) r
      3  from   student;
                     AGE                    R
                      18                    1
                      19                    2
                      20                    3
                      20                    3
                      20                    3
                      20                    3
                      21                    4
                      21                    4
                      21                    4
                      22                    5

  • Hibernate 2 SQL  query question

    thanks, I use hibernate 2.1
    Now I want to do the same thing, but using SQL
    THE_QUERY_STRING="UPDATE CUSTOMER_SOMETHING customerSomething set customerSomething.customer = (select customer.objectId FROM CUSTOMER customer where customer.customerId customerSomething.customerId) where customerSomething.userTask = 15608"
    With current THE_QUERY_STRING
    two parameters are missing...
    session.createSQLQuery(UPDATE_CUSTOMER_SQL, , );
    What should I put here?

    Hi,
    Use LAST to find the location_code related to the latest start_date, like this:
    SELECT       employee_id
    ,       MAX (start_date)     AS max_start_date
    FROM       position
    GROUP BY  employee_id
    HAVING       MIN (location_code) KEEP (DENSE_RANK LAST ORDER BY start_date)     = 25
    ;MIN (location_code) specifies what to do in case of a tie. In your case, ties are impossible, since (employee_id, start_date) is the primary key, so it doesn't matter if you say MIN or MAX (or, if you want to be cute, AVG or SUM) in the HAVING clause: you'll get the same location_code either way.
    I hope this answers your question.
    If not, post a little sample data (INSERT statements to go with the CREATE TABLE statement you've already posted), 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.
    See the forum FAQ {message:id=9360002}

  • [10g] Simple question on selecting a column in same record as a min value

    I have the following sample data to illustrate my question:
    CREATE TABLE     t_1
    (     c_a     VARCHAR2(1)
    ,     c_b     NUMBER(2)
    ,     c_c     DATE
    INSERT INTO     t_1
    VALUES('A',1,SYSDATE);
    INSERT INTO     t_1
    VALUES('A',2,SYSDATE+1);
    INSERT INTO     t_1
    VALUES('A',3,SYSDATE+2);
    INSERT INTO     t_1
    VALUES('A',4,SYSDATE+3);
    INSERT INTO     t_1
    VALUES('B',3,SYSDATE+6);
    INSERT INTO     t_1
    VALUES('B',4,SYSDATE+7);
    INSERT INTO     t_1
    VALUES('B',5,SYSDATE+8);I have the following query which allows me to select the value of c_c that corresponds with the minimum value of c_b grouped by c_a. In other words, my goal is: for each value in c_a, I want the value of c_c that corresponds with the minimum value of c_b.
    SELECT     t1.c_a
    ,     t1.c_c
    FROM     t_1 t1
         SELECT      c_a
         ,      MIN(c_b)     AS min_c_b
         FROM      t_1
         GROUP BY c_a
         ) t2
    WHERE     t1.c_a     = t2.c_a
    AND     t1.c_b     = t2.min_c_b
    ;This query works, but I'm wondering if there is a more efficient way to do this. Something without a subquery? I can't come up with anything else... It just gets a bit ugly with my real data, as there are probably 10 columns of data instead of 3. (Still only 1 minimum value though).

    Hi,
    Since you're using Oracle 10, you can do this:
    SELECT       c_a
    ,       MIN (c_c) KEEP (DENSE_RANK FIRST ORDER BY c_b)     AS c_of_min_b
    FROM       t_1
    GROUP BY  c_a
    ;This won't work in earlier versions.
    What do you want in case of a tie?
    For example, if we add one more row to the sample data:
    INSERT INTO     t_1 (c_a,  c_b,  c_c)
                 VALUES ('A',  1,    DATE '2001-01-01');Now there are two rows, one dated today and one dated 2001, that have an equal claim to being the "first" in group 'A', since they have the exact same value of c_b.
    The query above would display the row from 2001, that is, the earliest of the contenders. That's what MIN means in the query above. Instead of MIN, you can use any aggregate function, but, of course, that function has to work on your data type.
    If you want to show all the contenders in case of a tie, then you can stick with your original query, or you could use the analytic RANK function.
    WITH     got_rnk          AS
         SELECT     c_a, c_c
         ,     RANK () OVER ( PARTITION BY  c_a
                               ORDER BY          c_b
                        )   AS rnk
         FROM    t_1
    SELECT     c_a, c_c
    FROM     got_rnk
    WHERE     rnk     = 1
    ;This approach requires a sub-query, because analytic functions (like RANK) are computed after the WHERE clause is applied. If we want to use the results of an anlytic func tion in a WHERE clause, we have to compute the function in a suib-query first.

  • Why does Rank() have gaps and Dense_Rank() not have gaps in ranking ties in rows?

    Then encircled rows in the Rank / Dense_Rank examples below have ties for TotCnt.  Ex1 (using Rank()) has ties for TotCnt=19 and TotCnt=20.  Then TopCustomers rank jumps from 4 to 6.  In Ex2 (using Dense_Rank() for same set) has the same ties
    but the TopCustomers rank goes smoothly from 4 to 5 and so on incrementing by 1.  Why is this?  What is different from Rank() vs Dense_Rank()? 
    Use Northwind
    SELECT RANK() OVER (ORDER BY TotCnt DESC) AS TopCustomers, CustomerID, TotCnt
    FROM (SELECT CustomerID, COUNT(*) AS TotCnt
    FROM Orders Group BY CustomerID) AS Cust
    SELECT DENSE_RANK() OVER (ORDER BY TotCnt DESC) AS TopCustomers, CustomerID, TotCnt
    FROM (SELECT CustomerID, COUNT(*) AS TotCnt
    FROM Orders Group BY CustomerID) AS Cust
    Rich P

    DENSE_RANK() "Returns the rank
    of rows within the partition of a result set, without any gaps in the ranking. The rank of a row is one plus the number of distinct ranks that come before the row in question."
    Basically, DENSE_RANK() counts the number of distinct ranks prior to the current one, and adds one to it to determine the new rank. 
    https://msdn.microsoft.com/en-us/library/ms173825(v=sql.110).aspx
    RANK() "Returns the rank of each row within the partition of a result set. The rank of a row is one plus the number of ranks that
    come before the row in question."
    Basically, RANK() counts the number of ALL ranks prior to the current one, and adds one to it to determine the new rank.
    https://msdn.microsoft.com/en-us/library/ms176102(v=sql.110).aspx
    That difference is the reason for the two functions.
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Question on selecting the scenario in Import Wizard

    Hi,
    Which import scenario do we have to choose when importing the contents from BIAR file to Testing environment.
    1. Update the destination object. In case of name conflict, rename it.
    2. Update the destination object. In case of name conflict, do not import it.
    One more question:
    If we choose the first option, and if there is a name conflict. what will the object be renmaed as?
    For Example, say if the object name is employee_name, what will this object be renamed as?
    We are using BOE XI R 3.1.
    Thanks,
    Naveen
    Edited by: NR on May 13, 2009 8:52 PM

    Hi,
    Since you're using Oracle 10, you can do this:
    SELECT       c_a
    ,       MIN (c_c) KEEP (DENSE_RANK FIRST ORDER BY c_b)     AS c_of_min_b
    FROM       t_1
    GROUP BY  c_a
    ;This won't work in earlier versions.
    What do you want in case of a tie?
    For example, if we add one more row to the sample data:
    INSERT INTO     t_1 (c_a,  c_b,  c_c)
                 VALUES ('A',  1,    DATE '2001-01-01');Now there are two rows, one dated today and one dated 2001, that have an equal claim to being the "first" in group 'A', since they have the exact same value of c_b.
    The query above would display the row from 2001, that is, the earliest of the contenders. That's what MIN means in the query above. Instead of MIN, you can use any aggregate function, but, of course, that function has to work on your data type.
    If you want to show all the contenders in case of a tie, then you can stick with your original query, or you could use the analytic RANK function.
    WITH     got_rnk          AS
         SELECT     c_a, c_c
         ,     RANK () OVER ( PARTITION BY  c_a
                               ORDER BY          c_b
                        )   AS rnk
         FROM    t_1
    SELECT     c_a, c_c
    FROM     got_rnk
    WHERE     rnk     = 1
    ;This approach requires a sub-query, because analytic functions (like RANK) are computed after the WHERE clause is applied. If we want to use the results of an anlytic func tion in a WHERE clause, we have to compute the function in a suib-query first.

  • Question about correct use of WM_CONCAT

    Good morning,
    I'm trying to accomplish the following:
    starting with this
         ENAME
         ADAMS
         ALLEN
         BLAKE
    ...and ending with this
         OLD_NAME   NEW_NAME
         ADAMS      AADMS
         ALLEN      AELLN
         BLAKE      ABEKL
    ...basically, alphabetically sorting the characters inside each name. I have an intermediate step that looks promising
    select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
      from emp e,
           (select rownum pos from emp) iter
    where iter.pos <= length(e.ename)
    order by e.ename, substr(e.ename, iter.pos, 1);The above yields
    OLDNAME    NEWCHARPOS
    ADAMS      A
    ADAMS      A
    ADAMS      D
    ADAMS      M
    ADAMS      S
    ALLEN      A
    ALLEN      E
    ALLEN      L
    ALLEN      L
    ALLEN      N
    BLAKE      A
    BLAKE      B
    BLAKE      E
    BLAKE      K
    BLAKE      L
    ...the individual characters are in the right sequence, I figured all I had to do was to use WM_CONCAT (and replace the comma it inserts with the empty string) and I'd be done. I figured this would do it: (replace of comma left out for clarity)
    select oldname,
           wm_concat(newcharpos) newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
      group by oldname;but the sequence of newcharpos gets messed up in the process and, instead of the expected result, I get this:
    OLDNAME    NEWNAME
    ADAMS      A,S,M,D,A
    ALLEN      A,N,L,L,E
    BLAKE      A,L,K,E,B
    ...My question is, how do I structure the last query so the character order stays as calculated in the inner query ?
    Thank you for your help,
    John.

    Or
    SQL> select   oldname,
           wm_concat(newcharpos) keep (dense_rank last order by null)  newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
      group by oldname
    OLDNAME    NEWNAME                      
    ADAMS      A,A,D,M,S                    
    ALLEN      A,E,L,L,N                    
    BLAKE      A,B,E,K,L                    
    CLARK      A,C,K,L,R                    
    FORD       D,F,O,R                      
    JAMES      A,E,J,M,S                    
    JONES      E,J,N,O,S                    
    KING       G,I,K,N                      
    MARTIN     A,I,M,N,R,T                  
    MILLER     E,I,L,L,M,R                  
    SCOTT      C,O,S,T,T                    
    SMITH      H,I,M,S,T                    
    TURNER     E,N,R,R,T,U                  
    WARD       A,D,R,W                      
    14 rows selected.Or (11gR2)
    SQL> select ename oldname, column_value newname
      from emp,
           xmltable(('string-join(for $i in (' || rtrim(regexp_replace(ename, '(.)', '"\1",'),',') || ') order by $i return $i, "")'))
    OLDNAME    NEWNAME                      
    SMITH      HIMST                        
    ALLEN      AELLN                        
    WARD       ADRW                         
    JONES      EJNOS                        
    MARTIN     AIMNRT                       
    BLAKE      ABEKL                        
    CLARK      ACKLR                        
    SCOTT      COSTT                        
    KING       GIKN                         
    TURNER     ENRRTU                       
    ADAMS      AADMS                        
    JAMES      AEJMS                        
    FORD       DFOR                         
    MILLER     EILLMR                       
    14 rows selected.

  • Questions on Print Quote report

    Hi,
    I'm fairly new to Oracle Quoting and trying to get familiar with it. I have a few questions and would appreciate if anyone answers them
    1) We have a requirement to customize the Print Quote report. I searched these forums and found that this report can be defined either as a XML Publisher report or an Oracle Reports report depending on a profile option. Can you please let me know what the name of the profile option is?
    2) When I select the 'Print Quote' option from the Actions drop down in the quoting page and click Submit I get the report printed and see the following URL in my browser.
    http://<host>:<port>/dev60cgi/rwcgi60?PROJ03_APPS+report=/proj3/app/appltop/aso/11.5.0/reports/US/ASOPQTEL.rdf+DESTYPE=CACHE+P_TCK_ID=23731428+P_EXECUTABLE=N+P_SHOW_CHARGES=N+P_SHOW_CATG_TOT=N+P_SHOW_PRICE_ADJ=Y+P_SESSION_ID=c-RAuP8LOvdnv30grRzKqUQs:S+P_SHOW_HDR_ATTACH=N+P_SHOW_LINE_ATTACH=N+P_SHOW_HDR_SALESUPP=N+P_SHOW_LN_SALESUPP=N+TOLERANCE=0+DESFORMAT=RTF+DESNAME=Quote.rtf
    Does it mean that the profile in our case is set to call the rdf since it has reference to ASOPQTEL.rdf in the above url?
    3) When you click on submit button do we have something like this in the jsp code: On click call ASOPQTEL.rdf. Is the report called using a concurrent program? I want to know how the report is getting invoked?
    4) If we want to customize the jsp pages can you please let me know the steps involved in making the customizations and testing them.
    Thanks and Appreciate your patience
    -PC

    1) We have a requirement to customize the Print Quote report. I searched these forums and found that this report can be defined either as a XML Publisher report or an Oracle Reports report depending on a profile option. Can you please let me know what the name of the profile option is?
    I think I posted it in one of the threads2) When I select the 'Print Quote' option from the Actions drop down in the quoting page and click Submit I get the report printed and see the following URL in my browser.
    http://<host>:<port>/dev60cgi/rwcgi60?PROJ03_APPS+report=/proj3/app/appltop/aso/11.5.0/reports/US/ASOPQTEL.rdf+DESTYPE=CACHE+P_TCK_ID=23731428+P_EXECUTABLE=N+P_SHOW_CHARGES=N+P_SHOW_CATG_TOT=N+P_SHOW_PRICE_ADJ=Y+P_SESSION_ID=c-RAuP8LOvdnv30grRzKqUQs:S+P_SHOW_HDR_ATTACH=N+P_SHOW_LINE_ATTACH=N+P_SHOW_HDR_SALESUPP=N+P_SHOW_LN_SALESUPP=N+TOLERANCE=0+DESFORMAT=RTF+DESNAME=Quote.rtf
    Does it mean that the profile in our case is set to call the rdf since it has reference to ASOPQTEL.rdf in the above url?
    Yes, your understanding is correct.3) When you click on submit button do we have something like this in the jsp code: On click call ASOPQTEL.rdf. Is the report called using a concurrent program? I want to know how the report is getting invoked?
    No, there is no conc program getting called, you can directly call a report in a browser window, Oracle reports server will execute the report and send the HTTP response to the browser.4) If we want to customize the jsp pages can you please let me know the steps involved in making the customizations and testing them.
    This is detailed in many threads.Thanks
    Tapash

  • Satellite P300D-10v - Question about warranty

    HI EVERYBODY
    I have these overheating problems with my laptop Satellite P300D-10v.
    I did everything I could do to fix it without any success..
    I get the latest update of the bios from Toshiba. I cleaned my lap with compressed air first and then disassembled it all and cleaned it better.(it was really clean insight though...)
    BUT unfortunately the problem still exists...
    So i made a research on the internet and I found out that most of Toshiba owners have the same exactly problem with their laptop.
    Well i guess this is a Toshiba bug for many years now.
    Its a really nice lap, cool sound (the best in laptop ever) BUT......
    So I wanted to make a question. As i am still under warranty, can i return this laptop and get my money back or change it with a different one????
    If any body knows PLS let me know.
    chears
    Thanks in advance

    Hi
    I have already found you other threads.
    Regarding the warranty question;
    If there is something wrong with the hardware then the ASP in your country should be able to help you.
    The warranty should cover every reparation or replacement.
    But I read that you have disasembled the laptop at your own hand... hmmm if you have disasembled the notebook then your warrany is not valid anymore :(
    I think this should be clear for you that you can lose the warrany if you disasemble the laptop!
    By the way: you have to speak with the notebook dealer where you have purchased this notebook if you want to return the notebook
    The Toshiba ASP can repair and fix the notebook but you will not get money from ASP.
    Greets

  • Question regarding NULL and forms

    Hi all, i have a survey that im working on that will be sent via email.
    I'm having an issue though. if i have a multiple choice question, and the user only selects one of the choices, all the unselected choices return as NULL. is there a way i can filter out anytihng that says "NULL" so it only shows the selected options?
    thanks.
    here is the page that retrieves all the data. thanks
    <body>
    <p>1) Is this your first visit to xxxxxxx? <b><%=request.getParameter("stepone") %></b>
    </p>
    <p> </p>
    <p>2) How did You Learn About xxxxxxx?</p>
    <p><b><%=request.getParameter("steptwoOne") %></b>
      <br>
        <b><%=request.getParameter("steptwoTwo") %></b>
      <br>
        <b><%=request.getParameter("steptwoThree") %></b>
      <br>
        <b><%=request.getParameter("steptwoFour") %></b>
      <br>
        <b><%=request.getParameter("steptwoOther") %></b>
    </p>
    <p> </p>
    <p>3) What was your main reason for visiting xxxxx?</p>
    <p><b><%=request.getParameter("stepthreeOne") %></b>
        <br>
          <b><%=request.getParameter("stepthreeTwo") %></b>
        <br>
          <b><%=request.getParameter("stepthreeThree") %></b>
        <br>
          <b><%=request.getParameter("stepthreeFour") %></b>
        <br>
          <b><%=request.getParameter("stepthreeOther") %></b>
    </p>
    <p>4) did you find the information you were looking for on this site?</p>
    <p><b><%=request.getParameter("stepfour") %>
    <br>
    <b><%=request.getParameter("stepfourOther") %></b>
    </b></p>
    <p>5) Do you plan on using this website in the future?</p>
    <p><b><%=request.getParameter("stepfive") %></b></p>
    <p>6) What is your gender</p>
    <p><b><%=request.getParameter("stepsix") %></b></p>
    <p>7) What is your age group</p>
    <p><b><%=request.getParameter("stepseven") %></b></p>
    8) Would you like to take a moment and tell us how we can improve your experience on xxxxxxxxxx?
    <p><b><%=request.getParameter("stepeightFeedback") %></b></p>

    i was messing around and came up with this. it doesnt remove the null, but if it is null it adds ABC beside it. so i think i might be getting close. i just need to figure out how to replace the null.
    code]
    <b><%=request.getParameter("steptwoFour") %></b>
         <% if (request.getParameter("steptwoFour") == null ) {
         %>
         <% out.print("abc"); %>
         <% }
         %>

  • Anyone know how to remove Overdrive books from my iphone that have been transferred from my computer? They do not show up on itunes. I see a lot of answers to this question but they all are based on being able to see the books in iTunes.

    How do I remove Overdrive books from the library that were downloaded onto my computer then transferred to my iphone? The problem is that they do not show up in iTunes.
    I see this question asked a lot when I google, but they always give answers that assumes you can find the books in iTunes either under the books tab, or the audio books tab or in the music. They do not show up anywhere for me. They do not remove from the app like the ones I downloaded directly onto my iphone.the related archived article does not answer it either.  I even asked a guy working at an apple store and he could not help either.   Anybody...?
    Thanks!

    there is an app called daisydisk on mac app store which will help you see exactly where the memory is focused and consumed try using that app and see which folders are using more memory

  • Basic question

    Hello, i have a basic question. if i have defined 2 fields in a cube or a dso:
    Name Quantity
    and from the external flat file i get some characters for my quantity field. would my load fail?  for standard dso and for write optimized?
    NOTE: quantity field is a keyfigure defined as numeric.
    and the load coming in has "VIKPATEL" for Quantity field and not numbers.
    thanks

    Hi Vik,
    Yes, the load will fail.
    May be you coud first load this data into BW (into PSA) and set both fields as characters fields. Then you can create DSO, do transformation from this PSA to the DSO, and put your logic as to what do you want to do with those Quantity that is not number (e.g. convert to 0, or 'Not assgined', etc).
    You can use transfer rule, or a clean up ABAP code in the start routine.
    Hope this helps.

Maybe you are looking for

  • ITunes help error -- ver. 10.5

    I downloaded iTunes 10.5 and wanted to see if the help file said anything about iCloud.  I got a window that looked like a dead link in a web browser.  Is anyone else running into the same problem?

  • Automatic start dbconsole

    Hi all, I'm working with a two nodes RAC with 11.2 Enterprise edition All is running fine but, when I restart one of my servers, the dbconsole don't start automatically and I've to start it manually with emctl start command. How can I configure it to

  • Two ALV on Selection Screen

    Hi Abapers, I have small query <b>Can we add Two ALV on the selection Screen. I am not talking about OOALV or not Block ALV</b> Please suggest if it can be possible to create two ALV on screen using Simple ABAP.

  • Using Nano as flash drive...

    I used my 2nd gen nano as a flash drive to transfer music from my PC to my new mac. I deleted the files once they were transfered but when my ipod is connected all the empty space still shows up full as "other". What is the deal with that? Is there a

  • How to notify the rejected Purchase Requisition to the sender?

    We are working on Oracle Apps.11.0.3. Could anyone help me in this respect? My query is that : Suppose the Min-max planning is executed by an Inventory user.Then the Requisition Import Program executes,which has been scheduled to run at 17.00 hrs. Th