Possible bug using count in sort statement

I think there may be a bug in using count as the means to sort nodes. Below is an example of what I am describing. It appears that when the sort is performed the number of nodes is accurately calculated for each item. I printed the values out and hand counted the elements in the xml to ensure this to be the case. What appears to happen is the count value is treated as a string and not an integer, so the comparison is lexical string compare and not integer compare as would be expected. So 2 ends up being greater then 10. Has anyone else come across this?
<xsl:template name="Sort" >
<xsl:apply-templates select="//item">
          <xsl:sort order="descending" select="count(.//Skill[contains(@name,$SKILLS/@name)])"/>
</xsl:apply-templates>
</xsl:template>

Never mind. I am a total tard and forgot to set the data-type to number

Similar Messages

  • Help Using Count and SQL statements

    Hello
    This problem has been bugging me incesantly and I would be reaaaaaaally grateful if someone could help here
    I want to create query that woud count the number of times a certain unedited word would be matched against different edited words
    This query works well in MS ACCess but not in java
    query =" SELECT Count(*) AS WordCount, Segmentations.EditedWord FROM [select Segmentations.EditedWord FROM Segmentations where Segmentations.UneditedWord = '"+Word+"']. AS c GROUP BY Segmentations.EditedWord";
    I've tried removing the Segmentations. and changing it to
    query =" SELECT Count(*) AS WordCount, EditedWord FROM [select EditedWord FROM Segmentations where UneditedWord = '"+Word+"']. AS c GROUP BY EditedWord";
    But still nothing
    I think that is due to the fact that you can't call Count(*) and another field at the same time
    pleas eif anyone knows a way around this send it ASAP
    thanx

    Why not use,
    query = "SELECT Count(*) AS WordCount, EditedWord FROM Segmentations WHERE  UneditedWord = ? GROUP BY EditedWord"and use PreparedStatement to optimize.
    HTH

  • Possible bug using go tag with redirection under SSL?

    I've been testing an application under SSL and have noticed that some links "pop-out of SSL". Upon further inspection I noticed the links were using <go> tags with redirect set to true.
    Does anyone know where <go> gets the URL it uses? I'm wondering if this might be a webcache configuration issue or appserver config issue.
    note: using AS 10g 9.0.4.1.1
    Thanks in advance!
    /SFL

    Hi all,
    Just thought I'd update on resolution. As suspected, an AS config issue was responsible for this glitch. Long story short WebCache can communicate in 2 ways w/ an origin server (HTTP or HTTPS). You can have WebCache use SSL w/ the client and still communicate with the origin server using HTTP (which was our case). PITFALL: the origin server is unaware of the use of SSL by the client (WebCache only "knows"). SINCE THE ORIGIN SERVER IS THE ONE EXECUTING THE <GO> TAG, when using redirect=true attribute with the tag, the URL generated by the rewrite routine is HTTP and not HTTPS as one might expect when accessing the app via SSL.
    Hope I can spare someone else the headache...
    Cheers!
    /SFL

  • Creative' Entertainment Mode error (or possible bug) using X-fi Notebook c

    Hello,?
    Is there anyone,?with any ideas at all?
    Thanks?for?anything?you?can'think?of. Here's what I'm trying to do:
    ?A. Single?out?the?specific KB update,(If?it'sis?one?in?particular) which?causes?this?error. (For?possible?submission?to?Creative?Software?desi gners?to?look?into)?To which,
    I?have?re-installed?the?Vista?image?I?have,?from?when?Vista? Ultimate?x86(in?my?case, this time around)?install worked.
    I?turned off Automatic Vista Updates.
    ?I'm?going?to?attempt?to?download?them?at?a?time(o r?a?few?if?it'sdoesn't?let?me)?until this occurs again.
    B?This?time?I?am?going?to?install?SP?first,?unless ?there?are?updates,?which?are?needed?before?this?c an?occur.
    (In?that?event?I'll?document,?each?KB?prior?to?and ?after Vista SP)
    B. Get the Different OSes listing this issue over on the Dell Forums, for evaluation. See if there is any Vista version,
    ?(whether x86?or?x64)?That?doesn't?suffer?this?fate
    C. Accumulate?the?exact?total?of?E505/6400?Owners?with?X-Fi?Xtreme?Notebook?Cards,?that?have?this?issue. Report?my?finding?back,?here,?to?gather?an?exact?t otal.
    Dakotajoe?

    Hello,?
    Is there anyone,?with any ideas at all?
    Thanks?for?anything?you?can'think?of. Here's what I'm trying to do:
    ?A. Single?out?the?specific KB update,(If?it'sis?one?in?particular) which?causes?this?error. (For?possible?submission?to?Creative?Software?desi gners?to?look?into)?To which,
    I?have?re-installed?the?Vista?image?I?have,?from?when?Vista? Ultimate?x86(in?my?case, this time around)?install worked.
    I?turned off Automatic Vista Updates.
    ?I'm?going?to?attempt?to?download?them?at?a?time(o r?a?few?if?it'sdoesn't?let?me)?until this occurs again.
    B?This?time?I?am?going?to?install?SP?first,?unless ?there?are?updates,?which?are?needed?before?this?c an?occur.
    (In?that?event?I'll?document,?each?KB?prior?to?and ?after Vista SP)
    B. Get the Different OSes listing this issue over on the Dell Forums, for evaluation. See if there is any Vista version,
    ?(whether x86?or?x64)?That?doesn't?suffer?this?fate
    C. Accumulate?the?exact?total?of?E505/6400?Owners?with?X-Fi?Xtreme?Notebook?Cards,?that?have?this?issue. Report?my?finding?back,?here,?to?gather?an?exact?t otal.
    Dakotajoe?

  • Using alias in where statement

    simple sql:
    SELECT EMPLOYEE_ID,
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE EMPLOYEE_ID > 1000;
    is it somehow possible to use alias in where statement like
    SELECT EMPLOYEE_ID "ID",
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE "ID" > 1000;

    Hi,
    is it somehow possible to use alias in where statement likeWhy do you need it?
    To answer your question "Not directly"
    SQL> select empno eno, sal
      2  from emp
      3  where eno = 7900;
    where eno = 7900
    ERROR at line 3:
    ORA-00904: "ENO": invalid identifierColumn Alias are names given to give meaningful names to columns or the arithmetic operations' column.
    Twinkle

  • Count(*) in select statement having group by clause

    Hi
    I would like to use count(*) in select statement having group by clause. say for example there is a state with a number of cities listed. I would like to get the count of cities for each state.
    the sql stement is grouped by city and it is joined with 5 more tables.
    Thanks

    I suspect you want to look into analytic functions (assuming you have a recent version of Oracle). asktom.oracle.com has numerous examples if you do a search.
    Justin

  • Is it possible to use a case statement when joining different tables based on input parameters?

    Hi,
    I have a scenario where my stored procedure takes 5 parameters and the users can pass NULL or some value to these parameters and based on the parameters, I need to pull data from various tables.
    Is it possible to use a case statement in the join, similar the one in the below example. I'm getting error when I use the below type of statement.
    select a.*
    from a
    case
    when parameter1=1 then
    inner join a on a.id = b.id
    when parameter1=2 then
    inner join a on a.id = c.id
    end;
    Please let me know, if this type of statement works, and if it works will it create any performance issues?. If the above doesn't work, could you please give me some alternate solutions?
    Thanks.

    Here's a technique for joining A to B or C depending on the input parameters. In theory, you are joining to both tables but the execution plan includes filters to skip whichever join is not appropriate. The drawback is that you have to do outer joins, not inner ones.
    CREATE TABLE A AS SELECT LEVEL ak FROM dual CONNECT BY LEVEL <= 100;
    CREATE TABLE b AS SELECT ak, bk
    FROM A, (SELECT LEVEL bk FROM dual CONNECT BY LEVEL <= 10);
    CREATE TABLE c(ak, ck) AS SELECT ak, bk*10 FROM b;
    variable p1 NUMBER;
    variable p2 NUMBER;
    exec :p1 := 1;
    exec :p2 := 20;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.01 |       7 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |
    |*  5 |     FILTER            |                 |      1 |        |      9 |00:00:00.01 |       4 |
    |*  6 |      TABLE ACCESS FULL| B               |      1 |      9 |      9 |00:00:00.01 |       4 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |
    |*  8 |    FILTER             |                 |      1 |        |      0 |00:00:00.01 |       0 |
    |*  9 |     TABLE ACCESS FULL | C               |      0 |      9 |      0 |00:00:00.01 |       0 |
    Predicate Information (identified by operation id):
       1 - access("A"."AK"="ITEM_0")
       2 - access("A"."AK"="ITEM_1")
       3 - filter("A"."AK"<=9)
      5 - filter(:P1 IS NOT NULL)
       6 - filter(("B"."AK"<=9 AND "B"."BK"=:P1))
       8 - filter((:P2 IS NOT NULL AND :P1 IS NULL))
       9 - filter(("C"."AK"<=9 AND "C"."CK"=:P2))
    You can see that table C was not really accessed: the buffer count is 0.
    exec :p1 := NULL;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    Now table B is not accessed.
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.02 |       7 |      2 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.02 |       7 |      2 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |*  5 |     FILTER            |                 |      1 |        |      0 |00:00:00.01 |       0 |      0 |
    |*  6 |      TABLE ACCESS FULL| B               |      0 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |
    |*  8 |    FILTER             |                 |      1 |        |      9 |00:00:00.01 |       4 |      2 |
    |*  9 |     TABLE ACCESS FULL | C               |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |

  • Is it possible to use wildcards to match cell contents in an if statement?

    I need to return a ID along with some other information on a page by page basis, so that the information comes out linked by position.  I use a couple of loops and if statements to navigate through the document.  I am able to use exact matches of cell contents which is fine when the contents doesn't vary.  But the IDs, though they have a similar pattern, are all different. In a menu driven search, I am able to find what I need with '150^9^9^9^9^9-^9^9^9' But when I try putting this (or any number of [0-9], *, ? combinations) it fails.  Is it possible to use wildcards?  The symbol used for the match (==) makes me suspect that it is not possible and that only literal, exact matches will work.  But I wanted to check with the experts before giving up.
    Thanks
    pcbaz

    Thanks for the input.  You're right, a GREP search is much more efficient.  But what I'm trying to do and the circumstances here don't allow me, I think,  to go that route. I am trying to generate a list of values coming from several textframes on a single page and have them come out so that I can tell which values belong together.
    I'm using an inherited document with masters that were created 'manually';  the index numbering for textframes and tables is random. I navigate through the pages, looping through textframe indices asking ' does this textframe exist?' If so, I ask if it is a table -- if no, it is a simple textframe and I ask about the ID, if yes, I ask if the contents of cell (0,0) (invariant position and contents) are equal to the table I want..  I am sending the ID and other pieces of information from the table to one row of a new table on a new page.  So the ID and other information from a single page are linked by being in the same row.
    I know this a little 'off-normal' -- I'm using the search to navigate through the document and find things by location the way you do with a spreadsheet.  I have devised a work-around that helps me get around the fact that the ID is not invariant.  I create a list of the (exact) IDs from another document, equating them to a variable ('a').  I then loop through the list of IDs and ask if the contents of the textframe is equal to 'a'..This works o.k, unless there happens to be an extra space, a different kind of hyphen, etc. It would be so much easier if I could use the wildcards that work in a menu-driven text or GREP search in script just to ask about the contents of the textframe.
    Thanks again
    pcbaz (Peter BIerly)
    P.S. we have since rewritten the masters so this problem will not exist in the future -- we now know exactly which textframe and/or table indices to refer to to get any particular bits of information and don't need to ask questions about the contents.

  • Is it possible to use e.getsource with a switch statement?

    Is it possible to use e.getsource for a switch statement? I keep getting an error, which I understand. I'm just not sure if it can be done by using another method or casting e.getsource to something. Any ideas? Thanks!
         public void actionPerformed(ActionEvent e)
              switch(e.getSource())
                   //buttons 0 - 6
                   case buttons[0]:
                        Master_Clock.tickPos();
                        break;
                   case buttons[1]:
                        Master_Clock.tockPos();
                        break;
                   case buttons[2]:
                        Master_Clock.reset();
                        break;
                   case buttons[3]:
                        Master_Clock.tickNeg();
                        break;
                   case buttons[4]:
                        Master_Clock.tockNeg();
                        break;
                   case buttons[5]:
                        Master_Clock.dayPos();
                        break;
            }

    Using the same actionPerformed method for all the buttons is an obsolete technique.
    Use a seperate object implementing ActionListener with each button.
    There's a lot to be said for using Action objects, which you can also connect to key presses menu items and so on.
    Typically you create objects using the anonymous class technique. You'd do something like:
    Action tickAction = new AbstractAction("Tick") { // create anonymous action
       public void actionPerformed(ActionEvent e) {
          MasterClock.tickPos();
    JButton tickButton = new JButton(tickAction);

  • Sorting techinque without using sort statement /Comparing table fields.

    Hi,
    How to achieve sorting techinque without using sort statement in tables.
    Also how to compare fields of 2 custom tables and check their compatability without using code ?

    Hi,
    Refer the below program, it will be helpful.
    types: begin of t_int,
             int type i,
            end of t_int.
    data: it_int type standard table of t_int,
           wa_int type t_int,
           wa_int1 type t_int.
    wa_int-int = 70.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 50.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 20.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 30.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 23.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 23.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 32.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 77.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 99.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 1.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 11.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 90.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 40.
    append wa_int to it_int.
    clear wa_int.
    data: wk_line type i.
    data: cnt type i.
    data: cnt1 type i.
    describe table it_int lines wk_line.
    clear: cnt,cnt1.
    data wk_flag type c.
       clear wk_flag.
    while wk_line gt cnt1.
       cnt = cnt + 1.
       read table it_int into wa_int index cnt.
       cnt1 = cnt + 1.
       read table it_int into wa_int1 index cnt1.
       if wa_int-int lt wa_int1-int.
         modify it_int from wa_int index cnt1.
         modify it_int from wa_int1 index cnt.
         wk_flag = 'X'.
       endif.
       if cnt1 eq wk_line.
         clear: cnt, cnt1.
         if wk_flag eq 'X'.
         clear wk_flag.
         continue.
         else.
           exit.
         endif.
       endif.
    endwhile.
    loop at it_int into wa_int.
       write: / wa_int-int.
    endloop.

  • Is it possible to use "Delay Values" to create a frequency signal from digital "Count Edges" -task? (= are the results I'm getting correct?)

    Hello.
    I have a digital encoder from which I need freaquency information (to ultimately get rpm -infromation). The problem is that this task is inside a loop with 2 other DAQmx -tasks that are using "one sample on demand"-aquisition mode and if I configure this new counter task to be a freaquency task, it only updates once in ~ second which makes the whole loop lag.
    I thus created an "artificial" freaquency signal by using "Count Edges" -aquicition mode and the "Delay Values" -block so that I substract the delayed signal from original "Count Edges" -signal. There is a 0,01s delay in the loop and I figured out that if the history of the "Delay Values" -block is 100 samples I would thus get the real edge-freaquency.
    I tested this configuration and the results seem to be at least really close to correct but I have no idea if this idea is in any way correct...
    This explanation was probably quite confusing so please see the picture attached.
    Thanks a lot in advance! 
    Attachments:
    are_the_results_correct.jpg ‏200 KB

    First of all, thank you for quick reply. Unfortunately I don't have the acces to the vi. until tomorrow.
    And yes, I think you understood correctly: essentially this arragement measures how many edges have been counted during one iteration. This is how I figured out that this could then be used as a frequency measurement:
    1. From the "Edges - Delayed Edges" I get the information on how many edges have been counted during last iteration.
    2. I "know" (really I don't?) that one iteration lasts ~0,01s because of the delay in the loop.
    3. There is 2048 edges in one round of the encoder so I get the rpm as follows: rpm = (edges - delayed edges)/204,8*60(s)
    (If I was using history size of one as you suggested it would be: rpm = (edges-delayed edges)/2048 * 60) However using history size of 10 and taking it account in the multiplication smoothens the response nicely.
    But doesn't this arragement count on the fact that the vi runs smoothly and there is no additional lag?
    I quess using another loop and notifiers for a dedicated freaquency measurement as you suggested could be worth trying. I just have to first learn how to use them. 
    If I do use them will the main loop run smoothly and not wait for every update of the notifier? This would be essential since the freaquency output refresses only about once in a second if I use the continious aquisition mode.
    Attachments:
    are_the_results_correct.jpg ‏198 KB

  • Possible Bug In Apex 4.0.2

    Hi Everyone.
    I would like to report what I think is a bug in Apex 4.0.2.
    If you go to my workspace on apex.oracle.com:
    Workspace = EEG
    Username = [email protected]
    Password = galaxy (all lowercase)
    Run the application: 37796 - Elie_Various_Goodies [no credentials are required]
    This app was imported from my 4.0.1 workspace at my job. On the page I created two Date Picker items, P1_BEGIN_DATE and P1_END_DATE. I set them up so that whenever a user selects a begin date, a dynamic action "MANAGE_DATES" fires and automatically sets P1_END_DATE to this selected begin date value. Now when a user goes to select an end date, the displayed calendar starts at the previously selected begin date rather than the default of "Today".
    All of this worked fine on my office (4.0.1) workspace. However, after exporting this app and then importing onto apex.oracle.com, none of this functionality would work. Even worse, whenever I try to select a begin date or even an end date, the selected dates never make it into the date picker fields. Displaying the "Session" window shows these fields as empty.
    It was only after I copied the two date picker fields and also re-created my dynamic action (P1_BEGIN_DATE2, P1_END_DATE2, MANAGE_DATES) did my functionality return.
    This behavior is quite strange. I can only think this is some sort of bug attributed to the export/import process when exporting a 4.0.1 app into a 4.0.2 workspace. I am not sure if this bizarre behavior happens with non-date picker items. Nor am I sure if this beavior would be repeated if I export/import from 4.0.2 into the another 4.0.2 environment.
    Another strange thing I noticed. If I change my date picker items to be "date picker (classic)" type items, the dynamic action does not work at all. This is true in both 4.0.2 and 4.0.1. I'm not sure if this a bug or not. It could be that the classic date picker is just not "javascript" enabled so to speak. If that is true, then it would have been nice if the docs would have warned us about this.
    Has anyone else seen this behavior?
    Thank you.
    Elie

    Hi Joel.
    First let me thank you for the warning about allowing "everyone" access to my workspace.
    You're correct, of course. Anyone could destroy anything within my workspace. I guess I was too trusting especially as I have seen many posts on the Forum where others have given access to their workspace so that responders can offer help. I really should be more discreet about this. Again, thank you. Needless to say, I have changed my password.
    With respect to the possible bug, the MANAGE_DATES dynamic action is intended to be a submit page because that is the only way I can see to get BOTH the P1_END_DATE date picker item as well as the end date textual field to be assigned the selected P1_BEGIN_DATE. I tried to use a dynamic action in which javascript sets the value of the end date textual field to the selected P1_BEGIN_DATE value. This works without the need to submit the page. Unfortunately, this does not cause the P1_END_DATE date picker item to default to this value. Instead, the default remains at today's date. This is why I finally resorted to a dynamic action that submits the page whenever a new value is selected (that is, a "change" event) from the P1_BEGIN_DATE date picker item.
    All of this works in my office 4.0.1 environment. However, I was puzzled when this fails under 4.0.2 on the hosted web site at apex.oracle.com. This is why I posted a "possible" bug in 4.0.2.
    I hope this all makes sense.
    One more thing, as already mentioned in my original post, this "defaulting a date picker" functionality does NOT work at all for the "classic" date picker items in both 4.0.1 nor in 4.0.2. I realize one can implement this functionality (I' guessing) my using, say, a "onChange" javascript call to submit the page. It's just funny that the "classic" date picker items are not acted upon by the dynamic action MANAGE_DATES that submits the page.
    Thank you.
    Elie

  • CBO bug? Lack of SORT UNIQUE.

    Hi all,
    Let's consider following case:
    create table tmp as select rownum id, 0 sign from dual connect by level <= 100;
    create index tmp_i on tmp(id,sign);
    create table t as
    select mod(rownum,2) id, mod(rownum,3) val
    from dual
    connect by level <= 100000;
    begin
       dbms_stats.gather_table_stats (
          user,
          'T',
          estimate_percent   => null,
          method_opt         => 'FOR ALL COLUMNS SIZE SKEWONLY',
          cascade            => true
    end;
    begin
       dbms_stats.gather_table_stats (
          user,
          'TMP',
          estimate_percent   => null,
          method_opt         => 'FOR ALL COLUMNS SIZE SKEWONLY',
          cascade            => true
    end;
    /As you can see it scans TMP_I 50 000 times for statement with max (irrespective of distinct in subquery).
    Is there any way to enforce CBO to make SORT UNIQUE for max as well as for count so that it scans TMP_I only 3 times?
    SQL> select --+ leading(t) use_nl(t tmp)
      2  max(id)
      3  from tmp tmp
      4  where tmp.sign = 0
      5  and tmp.id in (select val from t where id = 1);
       MAX(ID)
             2
    | Id  | Operation           | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT    |       |      1 |        |      1 |00:00:00.14 |     159 |
    |   1 |  SORT AGGREGATE     |       |      1 |      1 |      1 |00:00:00.14 |     159 |
    |   2 |   NESTED LOOPS      |       |      1 |  49750 |  33333 |00:00:00.13 |     159 |
    |*  3 |    TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.02 |     156 |
    |*  4 |    INDEX RANGE SCAN | TMP_I |  50000 |      1 |  33333 |00:00:00.07 |       3 |
    Predicate Information (identified by operation id):
       3 - filter("ID"=1)
       4 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)
    SQL> select --+ leading(t) use_nl(t tmp)
      2  max(id)
      3  from tmp tmp
      4  where tmp.sign = 0
      5  and tmp.id in (select distinct val from t where id = 1);
       MAX(ID)
             2
    | Id  | Operation           | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT    |       |      1 |        |      1 |00:00:00.14 |     159 |
    |   1 |  SORT AGGREGATE     |       |      1 |      1 |      1 |00:00:00.14 |     159 |
    |   2 |   NESTED LOOPS      |       |      1 |  49750 |  33333 |00:00:00.13 |     159 |
    |*  3 |    TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.01 |     156 |
    |*  4 |    INDEX RANGE SCAN | TMP_I |  50000 |      1 |  33333 |00:00:00.07 |       3 |
    Predicate Information (identified by operation id):
       3 - filter("ID"=1)
       4 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)
    SQL> select --+ leading(t) use_nl(t tmp)
      2  count(id)
      3  from tmp tmp
      4  where tmp.sign = 0
      5  and tmp.id in (select val from t where id = 1);
    COUNT(ID)
             2
    | Id  | Operation            | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    |   0 | SELECT STATEMENT     |       |      1 |        |      1 |00:00:00.03 |     158 |       |       |          |
    |   1 |  SORT AGGREGATE      |       |      1 |      1 |      1 |00:00:00.03 |     158 |       |       |          |
    |   2 |   NESTED LOOPS       |       |      1 |      3 |      2 |00:00:00.03 |     158 |       |       |          |
    |   3 |    SORT UNIQUE       |       |      1 |  50000 |      3 |00:00:00.03 |     156 |  2048 |  2048 | 2048  (0)|
    |*  4 |     TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.01 |     156 |       |       |          |
    |*  5 |    INDEX RANGE SCAN  | TMP_I |      3 |      1 |      2 |00:00:00.01 |       2 |       |       |          |
    Predicate Information (identified by operation id):
       4 - filter("ID"=1)
       5 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)I can't figure out why SORT UNIQUE is absent for statement with max.
    PS. 11gR2

    Thanks for reply.
    user503699 wrote:
    I don't think it is a good idea to compare your last and first query timings as they are 2 different queries.Ok. I could compare query with max(id), sign(count(*)+1) vs max(id), sign(1). They always produce the same results so can be considered as the same.
    But I think that max(id), count(*) vs max(id) was enough to explain my point.
    user503699 wrote:
    If you are so sure of that you can write something like following :
    SQL> with data as (select /*+ materialize */ distinct val as val from t where id = 1)
    select max(id) from tmp tmp where tmp.sign = 0 and tmp.id in (select val from data) ;  2 
    I thought about that. I’m reluctant to use undocumented hints such as materialize. So folowing query has almost the best plan for my data:
    with data as (select distinct val as val from t where id = 1 and rownum > 0)
    select
    max(id)
    from tmp tmp
    where tmp.sign = 0
    and tmp.id in (select * from data);
    | Id  | Operation               | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                    
    |   0 | SELECT STATEMENT        |       |     1 |     8 |    50   (8)| 00:00:01 |                                                                    
    |   1 |  SORT AGGREGATE         |       |     1 |     8 |            |          |                                                                    
    |   2 |   NESTED LOOPS          |       |     3 |    24 |    50   (8)| 00:00:01 |                                                                    
    |   3 |    VIEW                 |       |     3 |     9 |    50   (8)| 00:00:01 |                                                                    
    |   4 |     HASH UNIQUE         |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                    
    |   5 |      COUNT              |       |       |       |            |          |                                                                    
    |*  6 |       FILTER            |       |       |       |            |          |                                                                    
    |*  7 |        TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                    
    |*  8 |    INDEX RANGE SCAN     | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                    
    Predicate Information (identified by operation id):                                                                                                  
       6 - filter(ROWNUM>0)                                                                                                                              
       7 - filter("ID"=1)                                                                                                                                
       8 - access("TMP"."ID"="DATA"."VAL" AND "TMP"."SIGN"=0)   And changing two hidden parameters may lead to the same plan as I expect:
    alter session set "_gby_hash_aggregation_enabled" = false;
    alter session set "_simple_view_merging" = false;
    with data as (select distinct val as val from t where id = 1)
    select
    max(id)
    from tmp tmp
    where tmp.sign = 0
    and tmp.id in (select * from data);
    | Id  | Operation             | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                      
    |   0 | SELECT STATEMENT      |       |     1 |    18 |    50   (8)| 00:00:01 |                                                                      
    |   1 |  SORT AGGREGATE       |       |     1 |    18 |            |          |                                                                      
    |   2 |   NESTED LOOPS        |       |     3 |    54 |    50   (8)| 00:00:01 |                                                                      
    |   3 |    VIEW               |       |     3 |    39 |    50   (8)| 00:00:01 |                                                                      
    |   4 |     SORT UNIQUE       |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                      
    |*  5 |      TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                      
    |*  6 |    INDEX RANGE SCAN   | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                      
    Predicate Information (identified by operation id):                                                                                                  
       5 - filter("ID"=1)                                                                                                                                
       6 - access("TMP"."ID"="DATA"."VAL" AND "TMP"."SIGN"=0)   But here I've got two additional questions:
    1. no_use_hash_aggregation can be used instead of "alter session set "_gby_hash_aggregation_enabled" = false;"
    What hint can be used instead of "alter session set "_simple_view_merging" = false;"?
    2. Is there any way to enforce CBO to use for this one
    select
    max(id)
    from tmp tmp
    where tmp.sign = 0
    and tmp.id in (select distinct val as val from t where id = 1 and rownum > 0);
    | Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                
    |   0 | SELECT STATEMENT            |       |     1 |     5 |     3   (0)| 00:00:01 |                                                                
    |   1 |  SORT AGGREGATE             |       |     1 |     5 |            |          |                                                                
    |   2 |   FIRST ROW                 |       |     1 |     5 |     1   (0)| 00:00:01 |                                                                
    |*  3 |    INDEX FULL SCAN (MIN/MAX)| TMP_I |     1 |     5 |     1   (0)| 00:00:01 |                                                                
    |*  4 |     FILTER                  |       |       |       |            |          |                                                                
    |   5 |      COUNT                  |       |       |       |            |          |                                                                
    |*  6 |       FILTER                |       |       |       |            |          |                                                                
    |*  7 |        TABLE ACCESS FULL    | T     |     2 |    12 |     2   (0)| 00:00:01 |                                                                
    -------------------------------------------------------------------------------------  the same plan as for this
    with data as (select distinct val as val from t where id = 1 and rownum > 0)
    select
    max(id)
    from tmp tmp
    where tmp.sign = 0
    and tmp.id in (select * from data);
    | Id  | Operation               | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                    
    |   0 | SELECT STATEMENT        |       |     1 |     8 |    50   (8)| 00:00:01 |                                                                    
    |   1 |  SORT AGGREGATE         |       |     1 |     8 |            |          |                                                                    
    |   2 |   NESTED LOOPS          |       |     3 |    24 |    50   (8)| 00:00:01 |                                                                    
    |   3 |    VIEW                 |       |     3 |     9 |    50   (8)| 00:00:01 |                                                                    
    |   4 |     HASH UNIQUE         |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                    
    |   5 |      COUNT              |       |       |       |            |          |                                                                    
    |*  6 |       FILTER            |       |       |       |            |          |                                                                    
    |*  7 |        TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                    
    |*  8 |    INDEX RANGE SCAN     | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                    
    I don't have anything against subquery factoring clause. Just for personal interest.
    (I have read topic "Thread: Materialize a Subquery without using "with" clause"
    Materialize a Subquery without using "with" clause
    user503699 wrote:
    If you are not going to change other things (like stats collection method, table/index structures etc.) which allow optimizer to choose better plan and you know your data better, you may need to be very specific with the hints and also may have to use additional hints in order to influence optimizer decisions.
    One way to do that would be to get the base details from oracle as follows (and tweak them) :I didn't find keyword "ADVANCED" in specification for DISPLAY_CURSOR Function in documentation. Nice trick.
    But anyway outline data makes sense only in case when query already has desirable execution plan.

  • Only on tempfile used during sql sorts

    environment : Entreprise 92010/W2K
    My temp tablespace (locally managed and temporary) has 3 tempfile, each with autoextend and maxsize limit.
    When i create an index on a big table, my 3 tempfile are used.
    But when a big sort occurs during a sql statement, only one tempfile is used and i get an ora-1652.
    Why all tempfiles are not used during sorts statements (union, max...) ?
    This behavior can be easily tested :
    - create a new temp ts with 3 small tempfile, autoextend on but very small maxsize
    - alter the user who will do the sorts
    - log on as user altered
    - create an index on a big table => the 3 tempfiles will grow
    - execute a query (max, min, union ,distinct...) => only one tempfile is used.
    SQL sort always done in only one file or bug ?
    Jean-Fran�ois L�guillier

    The 3 tempfile belong to the same ts.
    This ts is the temporary ts for my user which executes the sort sql statement.
    During execution, i monitor size of the 3 files (from v$tempfile) : only one was used during query and when it reached maxsize, i got ora 1652 but fres space were available in the 2 others tempfile.
    When i create a big index, i see changes in bytes for all tempfiles (in v$tempfile).
    One of my customer has same problem. He added tempfile to his temp ts but sort statement failed again.
    I tested this behavior with 92010/EE with W2K.
    I think it's a bug but nothing appears in patchset 9204.

  • Is it possible to use the scroll wheel of a mouse in list boxes?

    Hi,
    I was wondering if it is possible to use the scroll wheel in list boxes? LABview (6i under windows 98) does support the use in diagrams, for instance on case statements, but it does not appear to do much on the front panel apart from scrolling the whole thing up and down (and when pointing on the vertical scroll bar left and right).
    Is there a quick and easy way to get the scroll bar to work on list boxes, for instance by calling windows dll's? If so anyone ever done this?
    Any help will be greatly appreciated,
    Erik van Dijk

    Erik,
    Yes, it is possible. Anything is possible. LabVIEW is a programming language.
    However, the scope and ease of implementation may be beyond the amount of work you want to do. This must be accomplished through Windows API. This means the use of windows dlls and or Active X.
    Good luck.
    Also, try looking for toolkits. Someone out there supposedly has a toolkit for doing this sort of thing.

Maybe you are looking for

  • After disasters in iDVD `05, should I bother with `06?  Is it repaired?

    Hello, I appreciate any help possible, but am particularly interested in comments from "Len Goff" and "John Beatty1." This question involves a small experiment. I found errors in iDVD 5 that went unrepaired (yes, I did report them, once). There was n

  • Display with powerbook g4

    i've seen two displays being used as one display (applications can be dragged from one screen to the other, pretty much making one big screen) on a power mac g5. so i was wondering if this is possible with a powerbook screen. thanks

  • Bootcamp with Windows xp

    I need to use windows for my school programs. However, I am graduating in 3 months. Once I don't need those programs anymore, is there a way to rededicate the whole laptop to mac? Also, if I run Windows on a Mac, is it susceptible to viruses just lik

  • Classic scenario Configuration document

    Hi  Rama krishna C Teja , I'm Pawan,Presently we are implementing SRM -Classic scenario to our client .at present we are starting defining the Organizational structure? but there are many confusions....................... can you please send the conf

  • Location of photos

    I've had two hard drives for several yrs., keeping older photos on Drive D and current photos in Drive C.  I do genealogy, cemetery surveys, plus many family photos.  I've just bought a new computer 750 HD.  I'd like to get them in the Organizer, doe