Problems with "Select Distinct" Statement

Hi... I've a little problem with my SQL Statement...
I've a Table in a DataBase with Solds of the Month... the fields are: vta_fecha, vta_prod, vta_total, vta_mesa.
I've to Select only the distincts fields of vta_prod... selected by vta_fecha and vta_mesa...
My code is like this:         try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conec = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/POOL/Data/BaseDat.MDB");
            state = conec.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);try{
            rec = state.executeQuery("Select DISTINCT vta_prod, vta_fecha, vta_mesa from Ventas where vta_fecha = #" + Fecha_q + "# And vta_mesa = 0");           
            rec.first();
            int x = 0;
            while (rec.isAfterLast()==false){
                x++;
                rec.next();
            rec.first();
            if (x > 0){
                Productos = new String[x];
                Total_Vta = new int[x];
                Cant_Prod = new int[x];
                x = 0;
                while (rec.isAfterLast() == false){
                    Productos[x] = rec.getString("vta_prod");
                    rec.next();
                    x++;
            else{
                Productos = new String[0];
                Total_Vta = new int[0];
                Cant_Prod = new int[0];
        }catch(Exception e){JOptionPane.showMessageDialog(null,e.getMessage());}Now, in the Table I have only 3 diferents vta_prod, but this Statement returns 9 Rows... and I don't know why...
Please help me...
Regards...

I don�t have a complete picture because I don�t know what values you are passing in the select and I don�t know your column types but this is what I think is happening from what you have shared.
You may have misunderstood what the DISTINCT keyword does.
The DISTINCT keyword applies to the full set of columns in the select (not just the first column). So in your case it would be equivalent to:
SELECT vta_prod, vta_fecha, vta_mesa
FROM Ventas
WHERE ...
GROUP BY by vta_prod, vta_fecha, vta_mesa
So, it doesn't matter that you only have 3 distinct vta_prod values if you have multiple values being returned in the other columns. The vta_mesa column can only a return a single value as �0�. That leaves the vta_fecha column which is probably a date/time column and is probably the column that is returning the three other distinct values (one date with three distinct times).
(3 vta_prod) x (3 vta_fecha) x (1 vta_mesa) or 3x3x1 = 9 rows
So find a way to strip the time from vta_fecha in your select statement and your SQL should return the results you expect. I�m not an Access expect but I think I remember you can use something like the �Convert� or �DatePart� functions to make that happen (check your documentation to be sure)..
A couple of asides;
1) You should use a PreparedStatement and rarely if ever use Statement.
2) You should start Java variable names with lower case.

Similar Messages

  • "connect by" problem with "select distinct"

    When I run the following SQL (using "Scott" DB):
    select *
    from emp
    where deptno = 30 or mgr is null
    start with mgr is null
    connect by prior empno = mgr
    order siblings by ename
    I get the results one would expect. The President is first and all those reporting to him/her are listed in correct sequence.
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    7839,KING,PRESIDENT,,11/17/1981,5000,10
    7698,BLAKE,MANAGER,7839,5/1/1981,2850,30
    7499,ALLEN,SALESMAN,7698,2/20/1981,1600,300,30
    7900,JAMES,CLERK,7698,12/3/1981,950,30
    7654,MARTIN,SALESMAN,7698,9/28/1981,1250,1400,30
    7844,TURNER,SALESMAN,7698,9/8/1981,1500,0,30
    7521,WARD,SALESMAN,7698,2/22/1981,1250,500,30
    However, when I run the same query but make it "select distinct" I get the following:
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    7499,ALLEN,SALESMAN,7698,2/20/1981,1600,300,30
    7698,BLAKE,MANAGER,7839,5/1/1981,2850,,30
    7900,JAMES,CLERK,7698,12/3/1981,950,,30
    7839,KING,PRESIDENT,,11/17/1981,5000,,10
    7654,MARTIN,SALESMAN,7698,9/28/1981,1250,1400,30
    7844,TURNER,SALESMAN,7698,9/8/1981,1500,0,30
    7521,WARD,SALESMAN,7698,2/22/1981,1250,500,30
    Why would adding "distinct" to the select cause the result to be sorted STRICTLY by ename (per "order siblings by...")?
    Finally, if I "select distinct" but don't specify any "order" I get this, in NO APPARENT order:
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    7499,ALLEN,SALESMAN,7698,2/20/1981,1600,300,30
    7521,WARD,SALESMAN,7698,2/22/1981,1250,500,30
    7654,MARTIN,SALESMAN,7698,9/28/1981,1250,1400,30
    7698,BLAKE,MANAGER,7839,5/1/1981,2850,,30
    7839,KING,PRESIDENT,,11/17/1981,5000,,10
    7844,TURNER,SALESMAN,7698,9/8/1981,1500,0,30
    7900,JAMES,CLERK,7698,12/3/1981,950,,30
    Thanks in advance for any insight offered!
    -Gene

    you have to specify what is going to be the distict field.No you don't. DISTINCT keyword applies to the whole SELECT list. See your own link.
    In any case this does not appear to have anything to do with what you SELECT, rather that the SORT UNIQUE caused by the DISTINCT keyword appears to prevent the ORDER SIBLINGS BY clause from working correctly.
    Not really sure why you need DISTINCT in this example, no doubt this is being applied elsewhere. Given that you have duplicates in the rowset and that hierarchical query now supports views, perhaps it would be more efficient to apply DISTINCT keyword first, something like...
    SELECT e.*
    FROM (SELECT DISTINCT e.*
    FROM emp e
    WHERE e.deptno = 30
    OR e.mgr IS NULL) e
    START WITH e.mgr IS NULL
    CONNECT BY PRIOR e.empno = e.mgr
    ORDER SIBLINGS BY e.ename;
    Alternatively you could skip ORDER SIBLINGS BY clause and use SYS_CONNECT_BY_PATH function to get your order, something like...
    SELECT e.*
    FROM (SELECT DISTINCT e.*,
    SYS_CONNECT_BY_PATH () path
    FROM emp e
    WHERE e.depno = 30
    OR e.mgr IS NULL
    START WITH e.mgr IS NULL
    CONNECT BY PRIOR e.empno = e.mgr) e
    ORDER BY e.path
    Padders

  • OraException from Command.ExecuteReader with SELECT DISTINCT

    Hello
    I am trying to fill an OraDataReader object from a OraCommand object.
    It appears that whenever the statement includes a SELECT DISTINCT, the command fails (even though the SQL statement works fine when executed e.g. in TOAD)
    Dim Conn As OraConnection = New Oracle.DataAccess.Client.OraConnection("[Valid connection string]")
    Conn.Open()
    Dim Command As OraCommand = New OraCommand()
    Command.CommandType = CommandType.Text
    Command.CommandText = "select DISTINCT nvl(SUBFAMILY_COMPETENCY_ID, 0) SUBFAMILY_ID, nvl(NAME, ' ') NAME, FAMILY_COMPETENCY_ID FAMILY_ID " & _
    " from TAXONOMY_RELATIONAL, COMPETENCY " & _
    " where TAXONOMY_RELATIONAL.CL_ID = :1 " & _
    " AND COMPETENCY.cl_id (+) = TAXONOMY_RELATIONAL.cl_id and COMPETENCY.language_id (+) = :2 " & _
    " and COMPETENCY.COMPETENCY_ID (+) = TAXONOMY_RELATIONAL.SUBFAMILY_COMPETENCY_ID " & _
    " order by FAMILY_ID, SUBFAMILY_ID"
    Command.Parameters.Add("@CL_ID", context.Session!CLID)
    Command.Parameters.Add("@LANGUAGE_ID", context.Session!LANGUAGEID)
    Dim DataReader As OraDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection)
    An Oracle.DataAccess.Client.OraException is raised when executing the last statement, but no further details are given in the error message. The stack trace begins as follows
    [OraException]()
    Oracle.DataAccess.Client.OraException.HandleErrorHelper(Int32 errCode, OraConnection conn, IntPtr opsErrCtx, IntPtr opsSqlCtx, Object src, String procedure) +639
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(+737)
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(CommandBehavior behavior) +8
    The exception disappears as soon as I remove the DISTINT keyword from my SQL statement.
    Is this a bug or am I doing something wrong?
    Thanks for help,
    Bernt Fischer

    This issue is same as the one mentioned in the thread with title "Problem with 'Select distinct'" and the fix would be available in the next release.

  • Select distinct statement with various alias

    Hi everybody,
    I'm trying to put a select distinct statement in a query with two different alias for two different tables; like that:
    select distinct a.ma_name||'.'||a.ma_first_name d,
    a.ma_first_name||'.'||a.ma_name r
    from ma_main a, manager_liste b
    where (UPPER(b.manager_first_name||'.'||b.manager_name) = :APP_USER or
    (case when 'X'=:APP_USER or 'Y'=:APP_USER
    then 1
    else 0
    end) = 1)
    order by a.ma_name
    But it doesn't work. Can anybody help?
    Thx a lot!
    Jan

    hi,
    this is the error:
    1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    and the table manager_liste and ma_main are varchar tables.
    how can i make it work, so that my select list with submit does only show distinct names. Because right now it shows each name about 10 times....

  • Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination

    Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination
    Problem in committing transactions in Multiple Forms (Oracle Forms) with POST built-in command:
    Consider that the following statements are written in WHEN-WINDOW-CLOSED trigger of a called form.
    Statements in called form (Form name: FORM_CHILD):
    go_block('display_block') ;
    do_key('execute_query') ;
    -- Data from table_b will be populated in this block, based on the value of COLUMN_1 obtained
    -- from TABLE_A.
    -- Example: If the value of COLUMN_1 is 10, then all the matching records from TABLE_B, which
    -- are inserted with value 10 in TABLE_B.COLUMN_1 will be fetched and shown here.
    if user_choice = 'YES' then
    commit ;
    else
    rollback ;
    end if ;
    Statements in calling forms:
    There are two calling forms having following statements and it is going to call the above said called form.
    CALLING FORM 1
    Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...; Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    CALLING FORM 2:
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...;
    insert into table_b ...;
    Our understanding:
    Assume that both the forms are running from two different machines/instances, issuing commit at the same time. In this case, forms will start executing the statements written in ON-INSERT trigger, the moment POST command is executed. Though the commit is issued at the same time, according to oracle, only one of the request will be taken for processing first. Assume that calling form 1 is getting processed first.
    So, it fetches the value available in COLUMN_1 of TABLE_A and locks the row from further select, update, etc. as SELECT...FOR UPDATE command is used (note that NOWAIT is not given, hence the lock will be released only when COMMIT or ROLLBACK happens) and proceed executing further INSERT statements. Because of the lock provided by the SELECT...FOR UPDATE command, the statements in calling form 2 will wait for the resource.
    After executing the INSERT statements, the FORM_CHILD is called. The rows inserted in to TABLE_A will be queried and shown. The database changes will be committed when user closes the window (as COMMIT is issued in its WHEN-WINDOW-CLOSED trigger). Then the SELECT...FOR UPDATE lock will be released and calling form 2's statements will be executed.
    Actual happenings or Mis-behavior:
    Calling form 2 starts executing INSERT statements instead of waiting for SELECT...FOR UPDATE lock. Also, the value selected from TABLE_A.COLUMN_1 is same in both the calling forms, which is wrong.
    The rows inserted into TABLE_B are having similar COLUMN_1 values in calling form 2 and they are fetched and shown in the called form FORM_CHILD.
    Note that in calling form 2 also POST only is issued, but the changes posted there are accessible in calling form 1 also, which is wrong.
    Kindly suggest us as to how to fix above problem. It will be much use, if you can send us the information regarding the behavior of Oracle Forms POST built-in also.
    Our mail ID: [email protected]
    Thanks a lot in advance.

    You have several problems:
    1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
    2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
    All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
    Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics.

  • Problem with:  select 'c' as X from dual

    Problem with 'select 'c' as X from dual'
    I get 2 different results when I execute the above with SQLPlus (or java) depending on the instance I am connected to. For one instance the result is a single character and for the other the character is padded with blanks to 32 chars in the SQLPlus window (and java). Does anyone know what database setting causes this to happen? Is it a version issue ?
    Test #1: Oracle 9.2.0.6 - SQLPlus result is padded with blanks
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Dec 10 09:27:58 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.6.0 - Production
    SQL> select 'c' as X from dual;
    X
    c
    SQL>
    Test #2 Oracle 9.2.0.1 SQLPlus result is a single character.
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Dec 10 09:29:27 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL> select 'c' as X from dual;
    X
    c
    SQL>

    Using 9.2.0.6 On AIX 5.2 I get the single byte result:
    UT1 > select 'c' as X from dual;
    X
    c
    If the databases are on different Oracle Homes you may want to check the sqlplus global logon files for any set commands.
    If you executed the two sql statements from different OS directories you may also want to check your sqlpath for sqlplus .logon files.
    Try issueing clear columns and repeating the statement. Are the results the same?
    HTH -- Mark D Powell --

  • Problem with select max(FIELD)

    I have a table with the following fields:
    PARTID     ART_TYP     AEC     SERVICE     PLANT     STATUS
    4711     A     A     2     P     230
    4711     A     B     0     P     230
    4712     A     B     2     P     230
    4713     A     B     0     P     230
    I need a sqlscript where I get the records with MAX(SERVICE)
    In this example
    4711     A     A     2     P     230
    4712     A     B     2     P     230
    4713     A     B     0     P     230
    I tried this with:
    select distinct partid,
         art_typ,
         aec,
         max(service),
         plant,
         status
    from t_msltmp
    group by partid,art_typ,aec,plant,status
    But I get both records of partid=4711
    Can someone help me with this problem
    kind regards
    Menk Slot

    ROW_NUMBER() requires explicit ORDER BY clause in OVER:
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/functions105a.htm#86312
    SQL> select partid, art_typ, aec, mx, plant, status
      2  from(select partid,
      3                art_typ,
      4                aec,
      5                max(service) over (partition by partid) mx,
      6                row_number() over (partition by partid order by service desc) rn
      7                plant,
      8                status
      9         from t_t)
    10  where rn = 1
    11  /
        PARTID A A         MX P     STATUS
          4711 A A          2 P        230
          4712 A B          2 P        230
          4713 A B          0 P        230Rgds.
    P.S.
    Another way to get this (more tedoius):
    SQL> select partid,
      2  max(art_typ) keep (dense_rank first order by service desc) art_typ,
      3  max(aec) keep (dense_rank first order by service desc) aec,
      4  max(service) service,
      5  max(plant) keep (dense_rank first order by service desc) plant,
      6  max(status) keep (dense_rank first order by service desc) status
      7  from t_t
      8  group by partid
      9  /
        PARTID A A    SERVICE P     STATUS
          4711 A A          2 P        230
          4712 A B          2 P        230
          4713 A B          0 P        230Message was edited by:
    dnikiforov

  • I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    As I wrote Apple will diagnose an Apple product even if it is out of warranty for free. That should be your first step to find out if the problem is the battery or something else.
    Once you have Apple telling you a 7 month old battery is defective (if that turns out to be the case)  then it becomes a game of horse trading. You'll need to speak to the tech and when he tells you there is nothing he can do you will need to speak to the tech manager and when she says most likely there is nothing they can do you go to the store manager, etc.  It is unlikely (though possible) that they will give in easily you need to be firm, polite and let on that you're willing to accept a partial reimbursement.
    So again the first step is to find out what is wrong.
    good luck

  • Problem with selecting text in Adobe Reader XI

    Hi all, I am encountering a problem with Adobe Reader XI and it is very strange I could not find an alike issue on the internet so I guess I have to submit a question with it.
    So here it is, I am using Adobe Reader XI Version 11.0.2, operating system: Windows 7. I do not know it starts from when but it has the problem with selecting text - to be copied in pdf documents. I ensure that the documents are not scanned documents but word-based documents (or whatever you call it, sorry I cannot think of a proper name for it).
    Normally, you will select the text/paragraph you want to copy and the text/paragraph will be highlighted, but the problem in this case that I cannot select the text/paragraph, the blinking pointer (| <-- blinking pointer) will just stays at the same location so I cannot select/highlight anything to be copied. It happens oftenly, not all the time but 90%.
    This is very annoying as my work involves very much with copying text from pdf documents, I have to close the pdf file and then open it again so I can select the text but then after the first copying or second (if I am lucky), the problem happens again. For a few text I have to type it myself, for a paragraph I have to close all opening pdf documents and open again so I could select the paragraph to copy. I ran out of my patience for this, it causes trouble and extra time for me just to copying those texts from pdf documents. Does this problem happen to anyone and do you have a solution for this? I would much appreciate if you could help me out, thank you!

    Yeah,  I totally agree, this is very strange. I have always been using Adobe Reader but this problem only occurred ~three months ago. It must be that some software newly installed I think. But I have no idea.
    About your additional question, after selecting the texts and Ctrl + C, the texts are copied and nothing strange happens. It's just that right after I managed to copy the texts, it takes me a while to be able to select the texts again. For your information, I just tested to select the texts and then pressed Ctrl, the problem happened. And then I tried pressing C and then others letters, it all led to the problem.
    I guess I have to stick with left-clicked + Copy until I/someone figure the source of this problem. Thanks a lot for your help!

  • Problem with Selection Criteria with 2 or statements.

    I have a report with 2 or statements in the selection criteria:
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*"
    I am just trying to do do a count of records. The details has the record # and am doing a distinct count. If I rearrange this or statement, then I get a different count. The above statement gives me a count of 1136. If I rearrange the statement to:
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*"
    I only get 192 records. I don't understand why?  Please help.

    Cara,
    When Crystal evaluates an or statement it will stop evaluating after one of the clauses is true. Since the first or clause is returning data, true, it is not evaluating the other 2 clauses. When you change the order I am assuming that the first clause is returning data though different from the original record selection.
    You may want to consider using a command object or stored procedure to generate the filter as SQL should evaluate all the or clauses.

  • Performance problem with selecting records from BSEG and KONV

    Hi,
    I am having performance problem while  selecting records from BSEG and KONV table. As these two tables have large amount of data , they are taking lot of time . Can anyone help me in improving the performance . Thanks in advance .
    Regards,
    Prashant

    Hi,
    Some steps to improve performance
    SOME STEPS USED TO IMPROVE UR PERFORMANCE:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
    4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    5. Avoid using nested SELECT statement SELECT within LOOPs.
    6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
    7. Avoid using SELECT * and Select only the required fields from the table.
    8. Avoid nested loops when working with large internal tables.
    9. Use assign instead of into in LOOPs for table types with large work areas
    10. When in doubt call transaction SE30 and use the examples and check your code
    11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
    12. Use "CHECK" instead of IF/ENDIF whenever possible.
    13. Use "CASE" instead of IF/ENDIF whenever possible.
    14. Use "MOVE" with individual variable/field moves instead of "MOVE-
    CORRESPONDING" creates more coding but is more effcient.

  • Specific problem with buttons and states

    Hello,
    I first apologize for using Google Translate :-(
    I have a problem with InDesign not solve. It is for a digital publication.
    My goal is:
    A 'gallery' button is pressed and the ball image appears with three buttons: "Previous image", "Next image" and "close gallery".
    I do not want the gallery to be visible, or buttons that control, until the button is pressed "gallery", so I think all buttons except "gallery" with the "hidden until activated" option selected.
    I want the gallery, and buttons that control it, disappears when I press the button "close gallery".
    What I call "Gallery" is an image that fills the screen.
    After placing the image on your site have become the property button "Hidden until activated."
    Then convert this button in order to several states (what I will call "button states") and by the successive states with the images I want to show in the gallery.
    I think the interactions of the buttons.
    When button "gallery" I assign the following "I click the"
    - "Go to state"
    - Hide "gallery"
    - Show "close gallery"
    - Show "previous picture"
    - Show "next image"
    - Show "button states."
    The buttons "Previous Image" and "Next Image" are assigned, respectively, to go to previous state and go to the next state.
    When button "close gallery" I assign the following "I click the"
    - Show "gallery"
    - Hide "close gallery"
    - Hide "previous picture"
    - Hide "next image"
    - Show "button states."
    The buttons "Previous Image" and "Next Image" are assigned, respectively, to go to previous state and go to the next state.
    When button "close gallery" I assign the following "I click the"
    - Show "gallery"
    - Hide "close gallery"
    - Hide "previous picture"
    - Hide "next image"
    - Hide "button states."
    I put it up and working properly until I press "close gallery". Then I hide the buttons "close gallery", "previous image" and "next picture" but it keeps me visible "button states" showing the last image that was shown.
    Do not know how to fix this and I'm going crazy!
    Please can anyone help me?
    The solution may be another approach but without using "Folio Overlays".
    Thank you very much.

    I've moved your post to the DPS forum.
    I'm afraid the way you're doing this is not going to work with DPS.
    This should all be done with a multi state object. The first state would contain nothing but a button to go to the first state. After that set up each state with the proper buttons. Without seeing the file it's a bit difficult for me to envision exactly what you want to do.

  • Analitic functions (problem with SELECT)

    Hi!
    I've got a problem with analitic functions (I'm newbie in this topic).
    I have a table gpw_notowania which have colums: not_open, not_minimum, not_maximum, not_close, not_volume, not_sp_id and not_date.
    I need to receive from database the information: what is the open, minimum, maximum, close and sum of volume in every week? I have tried the code below but it tells me: ORA-01791 (marking not_date in ORDER clause).
    Help me, please.
    SELECT     distinct
         FIRST_VALUE(not_open)      OVER (partition by to_char(not_date,'WW') ORDER BY not_date)          as open,
         MIN(not_minimum)     OVER (partition by to_char(not_date,'WW') ORDER BY not_date)          as minimum,
         MAX(not_maximum)     OVER (partition by to_char(not_date,'WW') ORDER BY not_date)          as maximum,
         FIRST_VALUE(not_close)     OVER (partition by to_char(not_date,'WW') ORDER BY not_date DESC)     as close,
         sum(not_volume)          OVER (partition by to_char(not_date,'WW'))                    as volume
    FROM     gpw_notowania
    WHERE     not_sp_id = 80
    ORDER BY not_date;

    This is an interesting question.
    create table SortWithDistinct(Val1,Val2,sortKey,SubSortKey) as
    select 1,3,10,1 from dual union all
    select 1,3,10,1 from dual union all
    select 1,3,10,1 from dual union all
    select 2,4,30,2 from dual union all
    select 2,4,30,2 from dual union all
    select 3,5,20,1 from dual union all
    select 3,5,20,1 from dual union all
    select 4,6,10,3 from dual union all
    select 5,5,10,2 from dual union all
    select 5,5,10,2 from dual union all
    select 9,9,10,4 from dual union all
    select 6,4,20,2 from dual union all
    select 6,4,20,2 from dual union all
    select 7,3,30,1 from dual union all
    select 7,3,30,1 from dual;
    select distinct Val1,Val2
      from SortWithDistinct
    order by sortKey,SubSortKey;
    ORA-01791: not a SELECTed expressionIt is one way that we use "group by".
    for instance
    select Val1,Val2
      from SortWithDistinct
    group by Val1,Val2
    order by max(sortKey),max(SubSortKey);
    Val1  Val2
       1     3
       5     5
       4     6
       9     9
       3     5
       6     4
       7     3
       2     4It is one way that we use "Inline View".
    for instance
    select Val1,Val2
    from (select distinct Val1,Val2,sortKey,SubSortKey
    from SortWithDistinct)
    order by sortKey,SubSortKey;
    Furthermore, we may use below alternative solution which uses "dense_Rank".
    select Val1,Val2
    from (select distinct Val1,Val2,
          dense_Rank() over(order by sortKey,SubSortKey) as willSortKey
            from SortWithDistinct)
    order by willSortKey;Because "distinct" works after OLAP.
    for instance
    SQL> select distinct ColA,ColB,Row_Number() over(order by 1) as Rank
      2  from (select 1 as ColA,1 as ColB from dual
      3  union all select 1,1 from dual
      4  union all select 1,1 from dual
      5  union all select 1,1 from dual
      6  union all select 2,2 from dual
      7  union all select 2,2 from dual
      8  union all select 2,2 from dual)
      9  order by 1,2,3;
    ColA  ColB  Rank
       1     1     1
       1     1     2
       1     1     3
       1     1     4
       2     2     5
       2     2     6
       2     2     7my site :-)
    http://www.geocities.jp/oraclesqlpuzzle/1-6.html

  • Problem with selecting remote tables.

    Hi, im having problems with one select...
    Running select, in which i select tables from remote DB, takes not more then 2 seconds, retrieving few rows.
    1) When i try to "create table as" using that select it takes about 1 minute to run.
    2) Trying "merge into" my table using that select takes more that 5 minutes, ... replacing the select within merge by newly created temporary table (point 1) works fine - takes few seconds to run.
    So why simple select takes few seconds, creation of table using that select takes one minute and merge using that select takes 5minutes to run ?
    Thanks for any ideas
    Plan hash value: 1936184599
    | Id  | Operation                             | Name                        | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop | Inst   |IN-OUT|
    |   0 | MERGE STATEMENT                       |                             |     1 |   642 |    84  (12)| 00:00:02 |       |       |        |      |
    |   1 |  MERGE                                | NP_HT_REC        |       |       |            |          |       |       |        |      |
    |   2 |   VIEW                                |                             |       |       |            |          |       |       |        |      |
    |   3 |    NESTED LOOPS OUTER                 |                             |     1 |  8637 |    84  (12)| 00:00:02 |       |       |        |      |
    |*  4 |     HASH JOIN                         |                             |     1 |  8244 |    81  (13)| 00:00:01 |       |       |        |      |
    |*  5 |      HASH JOIN                        |                             |     1 |  4220 |    60  (10)| 00:00:01 |       |       |        |      |
    |*  6 |       HASH JOIN                       |                             |     1 |  4182 |    56   (9)| 00:00:01 |       |       |        |      |
    |   7 |        NESTED LOOPS                   |                             |     1 |  4134 |    41  (10)| 00:00:01 |       |       |        |      |
    |*  8 |         HASH JOIN                     |                             |     1 |  4109 |    40  (10)| 00:00:01 |       |       |        |      |
    |   9 |          REMOTE                       | HT_REC              |     2 |   170 |    11   (0)| 00:00:01 |       |       |   NP | R->S |
    |  10 |          VIEW                         | VW_SQ_3                     |   806 |  3167K|    29  (14)| 00:00:01 |       |       |        |      |
    |  11 |           SORT GROUP BY               |                             |   806 | 96720 |    29  (14)| 00:00:01 |       |       |        |      |
    |  12 |            MERGE JOIN                 |                             |   806 | 96720 |    28  (11)| 00:00:01 |       |       |        |      |
    |  13 |             SORT JOIN                 |                             |     2 |   170 |    12   (9)| 00:00:01 |       |       |        |      |
    |  14 |              REMOTE                   | HT_REC              |     2 |   170 |    11   (0)| 00:00:01 |       |       |   NP | R->S |
    |* 15 |             SORT JOIN                 |                             |  7100 |   242K|    16  (13)| 00:00:01 |       |       |        |      |
    |  16 |              REMOTE                   | T_UR_BUS               |  7100 |   242K|    14   (0)| 00:00:01 |       |       |   NP | R->S |
    |  17 |         REMOTE                        | T_UR                      |     1 |    25 |     1   (0)| 00:00:01 |       |       |   NP | R->S |
    |  18 |        REMOTE                         | T_UR_BUS               |  7100 |   332K|    14   (0)| 00:00:01 |       |       |   NP | R->S |
    |  19 |       REMOTE                          | HT_BUS                 |     3 |   114 |     3   (0)| 00:00:01 |       |       |   NP | R->S |
    |  20 |      VIEW                             | VW_SQ_4                     |     2 |  8048 |    21  (20)| 00:00:01 |       |       |        |      |
    |  21 |       REMOTE                          |                             |       |       |            |          |       |       |   NP | R->S |
    |  22 |     PARTITION RANGE ITERATOR          |                             |     2 |   786 |     3   (0)| 00:00:01 |   KEY |   KEY |        |      |
    |  23 |      TABLE ACCESS BY LOCAL INDEX ROWID| NP_HT_REC        |     2 |   786 |     3   (0)| 00:00:01 |   KEY |   KEY |        |      |
    |* 24 |       INDEX RANGE SCAN                | NP_HT_REC_IDX_UK |     2 |       |     1   (0)| 00:00:01 |   KEY |   KEY |        |      |
    Predicate Information (identified by operation id):
       4 - access("HB"."CHANGE_DATE"="VW_COL_1" AND "TUB"."BUNDLE_ID"="BUNDLE_ID")
           filter("ROWID"=ROWID)
       5 - access("TUB"."BUNDLE_ID"="HB"."BUNDLE_ID")
           filter("TUB"."DATE_CHANGE">="HB"."CHANGE_DATE")
       6 - access("HR"."USER_ID"="TUB"."USER_ID" AND "TUB"."DATE_CHANGE"="VW_COL_1")
           filter("HR"."CHANGE_DATE">="TUB"."DATE_CHANGE")
       8 - access("HR"."USER_ID"="USER_ID")
           filter("ROWID"=ROWID)
      15 - access(INTERNAL_FUNCTION("HR"."CHANGE_DATE")>=INTERNAL_FUNCTION("TUB"."DATE_CHANGE"))
           filter(INTERNAL_FUNCTION("HR"."CHANGE_DATE")>=INTERNAL_FUNCTION("TUB"."DATE_CHANGE"))
      24 - access("RES"."CHANGE_ID"(+)=TO_NUMBER(TO_CHAR("HR"."CHANGE_ID")) AND "RES"."REC_ID"(+)=TO_NUMBER(TO_CHAR("HR"."REC_ID")) AND
                  "RES"."SCHEDULE_ID"(+)=TO_NUMBER(TO_CHAR("HR"."SCHEDULE_ID")) AND "RES"."USER_ID"(+)=TO_NUMBER(TO_CHAR("HR"."USER_ID")) AND
                  "RES"."CHANGE_DATE"(+)=TO_DATE(INTERNAL_FUNCTION("HR"."CHANGE_DATE"),'dd.mm.yyyy hh24:mi:ss'))

    Have tried hint /*+NO_QUERY_TRANSFORMATION*/ and it is working fine now = 2seconds for merge :) Have no idea why is that, but it works
    thanks
    d.

  • Problem with the FOR statement.....again!

    Hi everyone,
    Well I'm still trying to do a car slideshow using external
    files and can't seem to see the end. The current movie is here:
    http://www.virtuallglab.com/projects.html
    I also attach the code. My problem is I had originally set up
    an animation with 2 pictures sliding in with some text, and then
    wait 4 seconds before sliding out, and then next pictures and text
    would slide in and so on, using a setInterval.
    The problem is the FOR loop seems to skip the setInterval and
    the function "wait", so it just loops quickly and jumps to last
    picture, so on the example above, it just slides the last picture
    (i=9) and that's it!
    Can you not include another function within a FOR statement.
    Or is there a way to tell the FOR loop to wait until all motion is
    finished?
    Any help greatly appreciated
    import mx.transitions.*;
    import mx.transitions.easing.*;
    for (i=0; i<10 ; i++) {
    var picLeft = "pics/"+i+".jpg";
    var picRight = "pics/"+i+"b.jpg";
    var txtToLoad = "text/"+i+".txt";
    this.createEmptyMovieClip("leftHolder",1);
    leftHolder.loadMovie(picLeft,i,leftHolder.getNextHighestDepth());
    leftHolder._x = -200;
    leftHolder._y = 15;
    var leftTween:Tween = new Tween(leftHolder, "_x",
    Strong.easeOut, leftHolder._x, 10, 2, true);
    this.createEmptyMovieClip("centerHolder",2);
    centerHolder.loadMovie(picRight,i+"b",centerHolder.getNextHighestDepth());
    centerHolder._x = 180;
    centerHolder._y = 250;
    var centerTween:Tween = new Tween(centerHolder, "_y",
    Strong.easeOut, centerHolder._y, 15, 2, true);
    text._x = 600;
    myData = new LoadVars();
    myData.onLoad = function(){
    text.carText.text = this.content;
    myData.load(txtToLoad);
    var textTween:Tween = new Tween(text, "_x", Strong.easeOut,
    text._x, 420, 2, true);
    myInterval = setInterval(wait, 4000);
    function wait() {
    var leftTweenFinished:Tween = new Tween(leftHolder, "_x",
    Strong.easeOut, leftHolder._x, -200, 1, true);
    var centerTween:Tween = new Tween(centerHolder, "_y",
    Strong.easeOut, centerHolder._y, 250, 1, true);
    var textTween2:Tween = new Tween(text, "_x", Strong.easeOut,
    text._x, 600, 1, true);
    clearInterval(myInterval);
    ***************************************************************************************** ***

    There is no way to tell a for loop to wait. That is not what
    they do.
    The entire for loop will execute (if possible, and it doesn't
    enter some kind of continuous infinite loop) completely before each
    time the frame is rendered.
    If you want to spread things out over time you need to use
    the setInterval -- but not inside a for loop! If you do that you
    immediately set however many intervals as your loop has. In this
    case you will also assign the ids for those intervals to the same
    variable, effectively overwriting the value so you will never be
    able to clear most of those intervals.
    So you need to rethink you whole structure. Set up some kind
    of counter and limit like this:
    var slidesToShow:Number=10;
    var curSlide:Number=0;
    Then have your setInterval increment the curSlide each time
    it is called and check to see if it has shown all of them. That is
    where your "loop" comes in.
    As for the other part of your question -- yes you actually
    have two different issues going on -- again you cannot make a for
    loop wait for anything. So no there is no way to pause it while you
    wait for your tween to end. But you can be notified when a tween
    ends.
    Check out the documentation about the tween class in the help
    files. There you will find the onMotionFinished event. So you can
    set up one of those to start whatever needs to be started when the
    tween has finished.
    You should also use the MovieClipLoader class to load your
    images, because you have no idea how long it will take to load
    them. Using that class you get a nice event (onLoadInit) that tells
    you when the asset is ready to be used.
    Finally I'm thinking you might want to use setTimeout instead
    of setInterval. It only goes once, while setInterval repeats
    forever. So I would think your algorithm would be something like
    this.
    1. load external asset
    2. when ready animate in and set onMotionFinished handler
    3. when motion is finished start loading next asset and
    setTimeout for 4 seconds.
    4. when 4 seconds is up or the clip is loaded (which ever
    takes longer) go to 2 and repeat.
    If this is going to be run locally on a hard drive or CD you
    won't have any problem with the length of time it takes to load the
    external assets, but if it is over the web it will take time.

Maybe you are looking for

  • How can I transfer photos from my iPhone to my Mac if I don't have iPhoto?

    When I connect my iPhone to iTunes I can't find a way to get hold of my pictures in my iPhone, does anyone know how I can import my iPhone photo library to my Mac? I don't have iPhoto, so it doesn't syncronize by itselt... Thanks!

  • LaserJet CP1025NW Color Printer - Weird cranking noise when printing or rotating carousel

    Just out the package today, the first time turning on the printer, during all print jobs and when rotating the cartridges, the carousel is making a weird cranking noise coming from the left side of the printer. I understand that this printer does mak

  • Preformance tuning,its urgent,i would appreciate ur help

    hi     I have some problem with performance tuning SELECT stlty            stlnr            stlkn            stpoz            idnrk       FROM stpo       INTO TABLE t_detail        FOR ALL ENTRIES IN t_header *MOD04{        WHERE stlnr eq t_header-st

  • What are the System Requirements for Web Server hosting Adobe Air application

    Working on a project that is using Adobe Air . The Adobe support site has system requirements for the client side application, but for the server side, what are the system requirements? Using a Windows server, would expect to have approx. 100 concurr

  • Songs on external hard drive

    So I am trying to put all my songs on to an external hard drive because I have too many songs and it slows down my computer.  My goal is to have all 25,000+ songs on a external drive as well as keep a couple albums on my internal drive just for when