SELECT query time-out - huge table

DBA dear friends,


DB version 11.1.0.7.  I have a SELECT query that is running long and wedging on. Query joins the 2 tables. It is partitioned hash (16 sheets) and others are not partitioned, each table is with the same volume of data - 230 million lines.

> Optimizer stats are not outdated

SELECT only 1 row (as indicated in the PLAN of EXPLAIN) should be fast.

Tags: Database

Similar Questions

  • query time-out

    Hello
    Oracle version: 8.1.7.4
    I run DBMS_STATS. GATHER_SCHEMA_STATS (ownname = > 'TOM') and now I need the time between one table and another.

    for example in dba_tables I have:
    TABLE_NAME          LAST_ANALYZED
    TAB1               2012/10/01 18:00:00
    TAB2               2012/10/01 19:00:00
    TAB3               2012/10/01 19:30:00
    TAB4               2012/10/01 19:40:20
    ...........................................
    ...........................................
    I want to get this result:
    TABLE_NAME_FIRST     TABLE_NAME_SECOND               ELAPSED_TIME
    TAB1                    TAB2                         1 h
    TAB2                    TAB3                         30 min     
    TAB3                    TAB4                         10 min - 20 sec.     
    How can anyone I write this query?

    Thanks in advance!

    I just checked again the 8i documentation:

    http://docs.Oracle.com/CD/A87860_01/doc/server.817/a85397/function.htm#88260

    Note: This function is limited to use with the analytical functions. It only accepts numbers as arguments and returns the interval literals.

    Then remove it and work directly on the difference in date to extract the days, hours, minutes, etc.

  • SQL query time-out


    Hello Experts,

    I received 2 days with a performance thing, but no luck.

    We have a custom user who runs specific sqls in an instance both Test and Prod. Prod its < 1 sec for each race to test everything taking more than 5 seconds. To do this, we have created a trigger to get the sqls. But I did not how to go further and compare things with env Prod.

    While the generation to explain the plan gives

    SQL > SELECT * FROM TABLE (dbms_xplan.display_cursor ('cavskqs3j74qr'));

    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID, cavskqs3j74qr, number of children 0

    begin XXINT_INV_ITEM_IMPORT.check_item (i_version_number = >: i_version_numb)
    o_return_message = >: o_return_message); end;

    NOTE: cannot fetch SQL_ID plan: cavskqs3j74qr, CHILD_NUMBER: 0
    Check the value of SQL_ID and CHILD_NUMBER;
    It could also be that the plan is no longer in the cursor cache (check v$ sql_plan)


    11 selected lines.

    You will appreciate if someone helps me on the same?

    Thank you

    Prabhat.

    Find out what is in: XXINT_INV_ITEM_IMPORT.check_item

    It is a function or a procedure or package, and inside, is the statement that goes wrong.

    It is the statement that you will need the execution plan of.

    If you have the active trigger (both on the prod and UN-made) you will have a lot of TRC files. This TRC file should mention somewhere

    XXINT_INV_ITEM_IMPORT.check_item

    Then you TKPROF this trace file, then you should be able to find higher education, even though the total runs only 5 seconds.

  • Complex query on a huge table

    Hello

    I have a table with about 100 million records. This table has 3 columns.

    Customer_id,
    start_date
    End_date

    Customer ID may be repeated with different ranges of start_date and end_date. Here is an example

    Customer ID Start_Date end_date
    --------------------------------------------------------------
    1 1 JANUARY 2013 MARCH 31, 2013
    1 APRIL 1, 2013 MAY 31, 2013
    1 1 JULY 2013 31 DECEMBER 2013
    2 1 MAY 2013 NULL
    2 1 JANUARY 2013 NULL


    I need to create another table with the output below

    Customer ID Start_Date end_date
    --------------------------------------------------------------
    1 January 1, 2013 may 31, 2013 - it has merged as the end date (March 31, 2013) and start date (April 1, 2013) can be merged to 1 card.
    1 July 1, 2013 31 December 2013 - it does not get merged as the end date (May 31, 2013) and the start date (July 1, 2013) have a gap
    2 1 January 2013 NULL - null value here is treated as an active record, so we choose the MIN of dates.


    Is thr a way to do it using a query. I have a pl - sql script where I added this logic.

    Samples of data and provided table structure. Thank you
    create table xx_temp (customer_id number,
    start_date date,
    end_date);
    
    insert into xx_temp values (1,to_date('01012013','ddmmyyyy'), to_date('31032013','ddmmyyyy'));
    insert into xx_temp values (1,to_date('01042013','ddmmyyyy'), to_date('31052013','ddmmyyyy'));
    insert into xx_temp values (1,to_date('01072013','ddmmyyyy'), to_date('31122013','ddmmyyyy'));
    insert into xx_temp values (2,to_date('01012013','ddmmyyyy'), null);
    insert into xx_temp values (2,to_date('01052013','ddmmyyyy'), null);

    Hello.

    {message: id = 10947774} shows how to do this.

    Use

    NVL ( end_date
         , DATE '9999-12-31'
         )
    

    to assimilate end_dates NULL with a incredibly late.

    Published by: Frank Kulash, 7 April 2013 07:01
    I see that you have added CREATE TABLE and INSERT statements, so I can test it. Thank you.

    Here is what you asked:

    CREATE TABLE     another_table
    AS
    WITH     got_new_grp     AS
    (
         SELECT     customer_id, start_date, end_date
         ,     CASE
                  WHEN  start_date > 1 + MAX (end_date) OVER
                                             ( PARTITION BY  customer_id
                                      ORDER BY      start_date
                                      RANGE BETWEEN UNBOUNDED PRECEDING
                                              AND     1      PRECEDING
                                       )
                  THEN  1
                  ELSE  0
              END          AS new_grp
         FROM     xx_temp
    --     WHERE     ...     -- if you need any filtering, put it here
    )
    ,     got_grp          AS
    (
         SELECT  customer_id, start_date, end_date
         ,     SUM (new_grp) OVER ( PARTITION BY  customer_id
                                       ORDER BY          start_date
                           )         AS grp
         FROM    got_new_grp
    )
    SELECT       customer_id
    ,       MIN (start_date)  AS start_date
    ,       MAX (end_date)    AS end_date
    FROM       got_grp
    GROUP BY  customer_id
    ,            grp
    ;
    

    There is no need to assimilate the NULL values with one incredibly late in this case. Ignore what I said about NVL.

    As you consider an end_date March 31, 2013, to overlap with an April 1, 2013 start_date, I changed

    start_date >= MAX (end_date) ....
    

    Since the wire more early to

    start_date > 1 + MAX (end_date) ....
    

    above.

  • Nested set tables in select query "in the clause of" take long time

    create or replace type t_circuitids is table of the varchar2 (100);

    -Under anonymous block continues to run away and never ends

    DECLARE
    v_circuitid t_circuitids;
    number of v_count;
    l_circuitids VARCHAR2 (4000)
    : = "Value1, value2, value3, value4, Value5";
    BEGIN
    -Query below converts the output concatinated with commas to the list and stores it in the nested table collection v_circuitids
    WITH an ACE
    (SELECT ',' | l_circuitids |) ',' AS circuitid
    THE DOUBLE)
    SELECT DISTINCT TRIM (SUBSTR (circuitid,
    INSTR (circuitid, "," 1, LEVEL) + 1.
    INSTR (circuitid, "," 1, LEVEL + 1)
    -INSTR (circuitid, "," 1, LEVEL)
    -1
    )
    ) cid
    LOOSE COLLECTION v_circuitid
    A
    CONNECT BY LEVEL <
    LENGTH (circuitid)
    -LENGTH (REPLACE (circuitid, ','));

    SELECT COUNT (1)
    IN v_count
    TABLE
    WHERE name IN (SELECT COLUMN_VALUE
    TABLE (v_circuitid));
    END;
    /

    -I had the question, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" that is used in code above is responsible for this.

    -Same code works fine in development and Test environments, but prod it continues to work on

    -I solved this problem by creating a temporary table, loading of all values in the collection in the temporary table and using this temporary table "in the clause" "

    -Can answer why his behavior like this when I use the collection where clause?

    -I use Oracle 9i

    Here is a summary of the question and the solution for this.

    -Nested type to collect multiple values

    CREATE or REPLACE the TYPE t_circuitid IS TABLE OF VARCHAR2 (100);

    Below the code will simply on the run.

    DECLARE
    v_circuitid t_circuitid;
    v_count NUMBER;
    BEGIN
    SELECT nal_name
    LOOSE COLLECTION v_circuitid
    OF fs_head
    WHERE groupid = 10;

    SELECT COUNT (1)
    IN v_count
    OF fs_attrib
    WHERE NAME IN (SELECT COLUMN_VALUE
    TABLE (v_circuitid));

    Dbms_output.put_line (v_count);
    END;
    /

    Cause:-SELECT COLUMN_VALUE TABLE (v_circuitid)); -This request is causing problem

    Why?  : - Because the CBO does not know how many lines is present in the collection, by default it takes 8168 lines

    Note:-always happens, it depends on the volume of data in the table, the path chosen by CBO. In my case, the table is huge on prod compared to DEV so he was causing a problem.

    -The following modified code works very well

    DECLARE
    v_circuitid t_circuitid;
    v_count NUMBER;
    BEGIN
    SELECT nal_name
    LOOSE COLLECTION v_circuitid
    OF fs_head
    WHERE groupid = 10;

    SELECT COUNT (1)
    IN v_count
    OF fs_attrib
    WHERE NAME IN (SELECT / * + cardinality (20 t) * /)
    COLUMN_VALUE
    TABLE (v_circuitid) t);

    Dbms_output.put_line (v_count);
    END;
    /

    Solution:-used as cardinality hint below.

    SELECT / * + cardinality (20 t) * / t COLUMN_VALUE TABLE (v_circuitid);

    Using cadinality I am saying CBO which dataset contains 20 lines or less.

    If it is version of Oracle 10 g and more, we can use below code (CARD utility).

    SELECT COLUMN_VALUE TABLE (CARD ((v_circuitid))

    For more information reach me at [email protected]

    Thank you best regards &,.

    Amarnath a. Reddy.

  • place a select query calculation in a different column in the same table

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    Hello

    2685870 wrote:

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:

    UPDATE dgpercentagedatachart

    Percentage of VALUE = 100,00 * totalcecrating

    / lowestfeederrating

    ;

    Noramlly, tables is not redundant columns like this.  If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change.  You can use a view to avoid having to encode them the calculation.

    If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Sinlge select query in the diff for the same table (same Structure) diagrams

    Scenario:

    Table XYZ is created in detail a.
    After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.

    For example

    A schema contains XYZ table with data from the year 2012
    Schema B contains XYZ table with data for the year 2011
    Table XYZ in the two schemas have an identical structure.

    So we can draw a single select query to read the data from the tables in an effective way.
    For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
    However, the data resides in 2 different schema altogether.


    Creating a view is an option.
    But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
    If the queries would be constituted by the ORM layer and are not generated by hand.
    So I can't use the view.
    So is there any option that would allow me to use only query on different scheme?

    970773 wrote:
    Scenario:

    Table XYZ is created in detail a.
    After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.

    For example

    A schema contains XYZ table with data from the year 2012
    Schema B contains XYZ table with data for the year 2011
    Table XYZ in the two schemas have an identical structure.

    So we can draw a single select query to read the data from the tables in an effective way.
    For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
    However, the data resides in 2 different schema altogether.

    Creating a view is an option.
    But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
    If the queries would be constituted by the ORM layer and are not generated by hand.
    So I can't use the view.

    Why not make the ORM as below?

    SELECT * FROM VIEW_BOTH;
    -VIEW_BOTH is a real VIEW of Oracle

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • What is the syntax for creating a global temporary table using a select query

    HII
    I create a global temporary table using a select query... How to speak of "on commit preserve rows ' who?


    create a table temporary global t1 select * from trn_ordbase on the lines of commit preserve;

    but this is an invalid syntax, then how to talk on commit preserve rows in this? If I don't mention, by default its recital on the validation of deleted rows.

    Please help me on this problem.
    create global temporary table t1 on commit preserve rows
      2  as select * from dual;
    
    Table created.
    
    TUBBY_TUBBZ?
    
  • If a select query is toggled (in CAR) it will restart the query or get out of the where he was?

    Assume that he has already extracted data and running (say join or sort) now and the node crashed, it will restart the query or out of there where he was

    As Hemant says, it "will resume' If your system is properly configured, but the way he is to restart the application, but not to send to the client data he already saw - so if you have a query that takes 5 minutes to send all the data and the instance crashes with 10 lines to go to the falied on request will take something like the same 5 minutes to get to the point where it can return the 10 rows.  (If in doubt, test).

    Concerning

    Jonathan Lewis

  • How to store results of the select query in the tables.

    I created a variable varray type and now want to assign some data of output of the select query in pl/SQL, as well as in reports 6i.

    You are in the wrong forum (this is for problems with the SQL Developer tool). You were the one where you have published first on the right, but not to reuse independent threads as you did.

    Kind regards
    K.

  • rowSetIterator.getRow (key) is null first time click ADF table row

    Hello experts, I have very strange problem in ADF table with multiple selection mode. First time when I select a folder and a command button press to treat the selected query, rowSetIterator.getRow (key) throws null pointer exception.   Second time click on any record command button and hit it again, rowSetIterator.getRow (key) does not throw an error it gives me rather recording.  Here is my code:

    < af:table value = "#{bindings.paymentList.collectionModel}" var = 'row' "

    Rows = "#{Bindings.paymentList.rangeSize} '"

    emptyText = "#{bindings.paymentList.viewable?" "{"No request found.":"Access Denied."}"

    columnStretching = "column: c8" width = "860px";

    fetchSize = "#{bindings.paymentList.rangeSize} '"

    disableColumnReordering = "true" rowBandingInterval = "1".

    inlineStyle = ' height: 400px; "

    filterModel = "#{bindings.paymentListQuery.queryDescriptor} '"

    queryListener = "#{bindings.paymentListQuery.processQuery} '"

    filterVisible = "true" varStatus = "vs."

    selectionListener = "#{viewScope.myBean.currentSelectionListener} '"

    rowSelection = "multiple".

    ID = "t1".

    Binding = "#{viewScope.myBean.MyTable}" >

    < af:column... >

    .....

    < / af:table >

    < af:commandButton text = "ProcessRequest".

    ID = "cbProcReq".

    Binding = "#{viewScope.myBean.processReqCB} '"

    action = "#{viewScope.myBean.processRequests}" > "

    < / af:commandButton >

    currentSelectionListener():


    rksSelectedRows = searchResultTable.getSelectedRowKeys ();

    If (rksSelectedRows! = null & &! rksSelectedRows.isEmpty ()) {}

    System.out.println ("rksSelectedRows is not null or empty");   / / always runs

    }

    }

    processRequests():

    RowKeySet rksSelectedRows = myTable.getSelectedRowKeys ();

    If (null! = rksSelectedRows & &! rksSelectedRows.isEmpty ()) {}

    Iterator itrSelectedRows = rksSelectedRows.iterator ();

    RowSetIterator rowSetIterator = dcItteratorBindings.getRowSetIterator ();

    While (itrSelectedRows.hasNext ()) {}

    Key = (Key) ((List) itrSelectedRows.next () .get (0);

    If (null! = rowSetIterator.getRow (key)) {//works only 2nd time click.}  First, click on throw null for getRow()

    PaymentReq paymentReq = (PaymentReq) ((DCDataRow) rowSetIterator.getRow (key)) .getDataProvider ();

    reqList.add (paymentReq);

    } else {}

    System.out.println ("getRow() is null");

    }

    }

    I noticed that the key is never null.  Something is still getting filled.    No idea why this glitch.  Why always 2nd time click work?

    I also checked thatRow myRow = rsiSelectedRows.getRow(key); is showing  myRow as null  for the first time. But  2nd time when I click and hit button,  myRow is not null !!  Do not know what is this glitch.


    Appreciate your help.

    Thank you

    Finally I was able to solve the problem.   Noticed that code clear filter in backing bean caused this problem.   I am clear the filter of bean support when the user forgets to clear the filter in the user interface and that caused the issue with table selection.  I commented on this code and table selection works perfectly well.

  • The query makes a full table scan?

    I have a simple select query that filters on the last 10 or 11 days of data in a table. In the first case, it runs in 1 second. In the second case it takes 15 minutes and still not done.

    I can say that the second query (11 days) makes a full table scan.
    -Why is this happening? ... I guess some kind of threshold?
    -Are there a way to avoid this? ... or encourage Oracle to play nice.

    I find confusing from the point of view before end/query to get very different performances.

    Jason
    Oracle 10g
    Toad quest 10.6

    CREATE TABLE delme10 AS 
    SELECT *
    FROM ed_visits
    WHERE first_contact_dt >= TRUNC(SYSDATE-10,'D');
    
    Plan hash value: 915912709
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT       |                   |  4799 |  5534K|  4951   (1)| 00:01:00 |
    |   1 |  LOAD AS SELECT              | DELME10           |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| ED_VISITS         |  4799 |  5534K|  4796   (1)| 00:00:58 |
    |*  3 |    INDEX RANGE SCAN          | NDX_ED_VISITS_020 |  4799 |       |    15   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-10,'fmd'))
    
    
    CREATE TABLE delme11 AS 
    SELECT *
    FROM ed_visits
    WHERE first_contact_dt >= TRUNC(SYSDATE-11,'D');
    Plan hash value: 1113251513
    
    -----------------------------------------------------------------------------------------------------------------
    | Id  | Operation              | Name      | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    -----------------------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT |           | 25157 |    28M| 14580   (1)| 00:02:55 |        |      |            |
    |   1 |  LOAD AS SELECT        | DELME11   |       |       |            |          |        |      |            |
    |   2 |   PX COORDINATOR       |           |       |       |            |          |        |      |            |
    |   3 |    PX SEND QC (RANDOM) | :TQ10000  | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | P->S | QC (RAND)  |
    |   4 |     PX BLOCK ITERATOR  |           | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | PCWC |            |
    |*  5 |      TABLE ACCESS FULL | ED_VISITS | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | PCWP |            |
    -----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - filter("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-11,'fmd'))

    This seems to change the plan to explain it...

    alter session set optimizer_index_cost_adj=10;
    
  • SQL - last selection query save values for each date in term

    Hello

    Can anyone help me please with my problem.

    I'm trying to get the last balance recorded for each day of specific box (1 or 2) in a given period of days of the database ms access using ADOTool.

    I'm trying to get this information with SQL query but so far without success.

    My table looks like this:

    Name of the table: TestTable

    Date         Time      Location  Box  Balance
    20.10.2014.  06:00:00     1       1    345
    20.10.2014.  12:00:00     1       1    7356
    20.10.2014.  18:45:00     1       1    5678
    20.10.2014.  23:54:00     1       1    9845
    20.10.2014.  06:00:02     1       2    35
    20.10.2014.  12:00:04     1       2    756
    20.10.2014.  18:45:06     1       2    578
    20.10.2014.  23:54:10     1       2    845
    21.10.2014.  06:00:00     1       1    34
    21.10.2014.  12:05:03     1       1    5789
    21.10.2014.  15:00:34     1       1    1237
    21.10.2014.  06:00:00     1       2    374
    21.10.2014.  12:05:03     1       2    54789
    21.10.2014.  15:00:34     1       2    13237
    22.10.2014.  06:00:00     1       1    8562
    22.10.2014.  10:00:00     1       1    1234
    22.10.2014.  17:03:45     1       1    3415
    22.10.2014.  22:00:00     1       1    6742
    22.10.2014.  06:00:05     1       2    562
    22.10.2014.  10:00:16     1       2    123
    22.10.2014.  17:03:50     1       2    415
    22.10.2014.  22:00:10     1       2    642
    23.10.2014.  06:00:00     1       1    9876
    23.10.2014.  09:13:00     1       1    223
    23.10.2014.  13:50:17     1       1    7768
    23.10.2014.  19:47:40     1       1    3456
    23.10.2014.  21:30:00     1       1    789
    23.10.2014.  23:57:12     1       1    25
    23.10.2014.  06:00:07     1       2    976
    23.10.2014.  09:13:45     1       2    223
    23.10.2014.  13:50:40     1       2    78
    23.10.2014.  19:47:55     1       2    346
    23.10.2014.  21:30:03     1       2    89
    23.10.2014.  23:57:18     1       2    25
    24.10.2014.  06:00:55     1       1    346
    24.10.2014.  12:30:22     1       1    8329
    24.10.2014.  23:50:19     1       1    2225
    24.10.2014.  06:01:00     1       2    3546
    24.10.2014.  12:30:26     1       2    89
    24.10.2014.  23:51:10     1       2    25
    ...
    

    Let's say that the period is 21.10.2014. -23.10.2014. and I want to get the last balance recorded for zone 1. for each day. The result should look like this:

    Date         Time      Location  Box  Balance
    21.10.2014.  15:00:34     1       1    1237
    22.10.2014.  22:00:00     1       1    6742
    23.10.2014.  23:57:12     1       1    25
    

    So far, I managed to write a query that gives me the balance so that a SINGLE date (date more time in the table), but I need balance for EACH date in a specific period.

    My incorrect code (has not managed to implement "BETWEEN" for the dates...):

    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    

    TNX!

    NP

    Here's the correct query (just copy - paste):

    SELECT
    T1.Date,
    T1.Time,
    T1.Location,
    T1.Box,
    T1.Balance
    FROM TestTable T1
    INNER JOIN (
    SELECT
    MAX(Time) AS Max_Time
    FROM TestTable
    WHERE Location=1 AND Box=1 AND Date BETWEEN #10/27/2014# AND #11/1/2014#
    GROUP BY Date) T2
    ON T1.Time=T2.Max_Time;
    

    The problem is in the SELECTION within the INNER JOIN. This SELECTION selects the time max for each date, because we want this and then the entire table, we choose filelds we want, but now we have only fields with the time max.

    Here is a really good explanation of INNER JOIN if anyone is interested--> JOINT INTERNAL

    Peace!

  • How to select a record in one table to manipulate data in a database?

    Hello community,

    Using 32-bit Labview 2015.

    I created a user interface that runs a query and retrieves my table from a sql database.

    I want to be able to manage only one record at a time by selecting the record in my table and then manipulate the data according to the needs.

    Whenever the user runs a query, I want as the first record in the table to be selected / highlighted.

    I want an indicator that is currently active.

    Then a click of a button, to be able to scroll the actively selected record.

    Once I have the selected record, I want a way to write a query to edit or delete the record.

    Is attached a photo of my query to select all of my table and connect data in my table (results).

    Attached a photo of my painting showing the timeline of my sql database.

    What is the best way to go on a record selection in a table and the modification of data with a query?

    Any help would be greatly appreciated.

    Thank you

    I guess that's not a table, but multi-column listbox.

    Right click, select--> highlight whole line selection Mode

    The value of the multicolumn listbox is the row index - you can write a local variable to highlight the line, the event structure to handle the user clicking on, etc.

    If you enable the property editable ListBox cells, you can allow users to edit the items of the listbox.

    If you want to get the data in row, you hint REF table and work with the array of strings in row - convert it to cluster, etc..

    I don't know, what type of data, it is, how you structure the database looks like, I don't even know if you use the wrapper to work with the database, I can't write queries for you.

    Something like Update Tablica Set Serial = '5' where ID = '22';

Maybe you are looking for

  • Firefox always opens at 120%. How can I change this permanently?

    When I open Firefox, the zoom is still at 120%. How can I change this permanently?

  • The M70-267 Satellite internal memory card reader does not work

    Hello Internal memory card reader no longer works on my M70-267.Device Manager reports the error with the driver of the bus PCI 6 mass storage controller, device 4, function 3.The first problem, the result of this is? Help, pleasethanx

  • HP Envy m6-1090ee (left hinge damaged)

    I bought my HP Envy in Dubai (29/08/2013), where I live and use computers laptops HP for 10 years now and never had any problems!  Even was with my last purchase - Envy, until today, when I tried to close my laptop screen and I felt the resistance an

  • PrinterCommunicationSystemEncounteredaProblemandNeeds to end

    Help, please!  I have 2 impressions stuck in my printer (network printer) and mark despite the fact that I tried to cancel, they will not disappear. The printer itself says there is no jobs to cancel, but when I go to the Control Panel printer it sti

  • Need to brick transformer room for QuickDock

    I have a Pavilion dv6000 with a recently acquired QuickDock (ES631AA #ABA). I need a transformer for the QuickDock brick. It requires the power of 18.5V, 3. 5A or 19V, 4. 74. can you provide a p/n of transformer brick of HP to address appropriate for