Slow query results for simple select statement on Exadata

I have a table with 30+ million rows in it which I'm trying to develop a cube around. When the cube processes (sql analysis), it queries back 10k rows every 6 seconds or so. I ran the same query SQL Analysis runs to grab the data in toad and exported results, and the timing is the same, 10k every 6 seconds or so. r
I ran an execution plan it returns just this:
Plan
SELECT STATEMENT  ALL_ROWSCost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576       
     1 TABLE ACCESS STORAGE FULL TABLE DMSN.DS3R_FH_1XRTT_FA_LVL_KPI Cost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576  I'm not sure if there is a setting in oracle (new to the oracle environment) which can limit performance by connection or user, but if there is, what should I look for and how can I check it.
The Oracle version I'm using is 11.2.0.3.0 and the server is quite large as well (exadata platform). I'm curious because I've seen SQL Server return 100k rows ever 10 seconds before, I would assume an exadata system should return rows a lot quicker. How can I check where the bottle neck is?
Edited by: k1ng87 on Apr 24, 2013 7:58 AM

k1ng87 wrote:
I've notice the same querying speed using Toad (export to CSV)That's not really a good way to test performance. Doing that through Toad, you are getting the database to read the data from it's disks (you don't have a choice in that) shifting bulk amounts of data over your network (that could be a considerable bottleneck) and then letting Toad format the data into CSV format (process the data adding a little bottleneck) and then write the data to another hard disk (more disk I/O = more bottleneck).
I don't know exedata but I imagine it doesn't quite incorporate all those bottlenecks.
and during cube processing via SQL Analysis. How can I check to see if its my network speed thats effecting it?Speak to your technical/networking team, who should be able to trace network activity/packets and see what's happening in that respect.
Is that even possible as our system resides off site, so the traffic is going through multiple networks.Ouch... yes, that could certainly be responsible.
I don't think its the network though because when I run both at the same time, they both are still querying at about 10k rows every 6 seconds.I don't think your performance measuring is accurate. What happens if you actually do the cube in exedata rather than using Toad or SQL Analysis (which I assume is on your client machine?)

Similar Messages

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

  • Simple Select statement in MS Access

    I am not able to get this simple select statement working in MS Access.
    "SELECT PhotoLocation from RfidData WHERE TeamID = '"+teamID ;
    It is using a variable called teamID which is a string.
    The error is java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression
    Please Suggest
    Thank You...

    Let's look at your code, shall we?
    public String readPhotoLoc(String teamID)
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection(dbURL,"","");
        PreparedStatement ps = con.prepareStatement("Select PhotoLocation from RfidData ");  // There's no bind parameter here, so setString will do nothing
    ps.setString(1,teamID);
    ResultSet rs = ps.executeQuery();  // what do you do with the ResultSet?  Nothing.  //You don't return anything,  either.  I doubt that this mess even compiles.
    }Here's one suggestion for how to write it properly:
    public String readPhotoLoc(Connection connection, String teamID)
        String photoLoc = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
        try
            String query = "SELECT PhotoLocation FROM RfidData WHERE TeamID = ?";
            ps = connection.prepareStatement(query);
            ps.setString(1,teamID);
            rs = ps.executeQuery();
            while (rs.next())
                photoLoc = rs.getString("PhotoLocation");
            return photoLoc;
        catch (SQLException e)
              e.printStackTrace();
               return null;
        finally
              try { if (rs != null) rs.close(); } catch (SQLException ignoreOrLogThis) {}
              try { if (ps != null) ps.close(); } catch (SQLException ignoreOrLogThis) {}
    }Make sure that the types of the columns match the Java types.
    %

  • How to Edit Query Result of Simple Search Panel

    Hi Experts,
    I have a question regarding Simple Search Panel.
    I have made a VO that select a table which contained data like this:
    Name | Skill | Status
    Rooney | Shooting | A
    Rooney | Heading | B
    Rooney | Running | B
    Van Persie | Shooting | A
    Van Persie | Heading | C
    Van Persie | Running | B
    I successfully made a Simple Search Panel which showing all the data from that VO.
    But my requirement is I want to make a grouping of that search result, so it should be showing like this:
    Name | Skill | Status
    Rooney | Shooting | A
    - - - - - - | Heading | B
    - - - - - - | Running | B
    Van Persie | Shooting | A
    - - - - - - | Heading | C
    - - - - - - | Running | B
    As long as it is the same person with the row above, it won't print the name of the person.
    Could you please give me a pointer about this?
    Thanks in advance,
    Rheza
    Edited by: 893922 on Feb 19, 2013 3:13 AM

    Hi expert,
    My requirement is I need to override the query result from Simple Search Panel.
    The data that I provided above was just for simplify the example.
    One of my requirement is:
    - when the "status" column value is 0, I need to override this and show an image of image0.jpg
    - when the "status" column value is 1, I need to override this and show an image of image1.jpg
    Any pointers about this will be so much appreciated.
    Thanks,
    Rheza
    Edited by: 893922 on Mar 6, 2013 7:26 PM

  • How to find for which select statement performance is more

    hi gurus
    can anyone suggest me
    if we have 2 select statements than
    how to find for which select statement performance is more
    thanks&regards
    kals.

    hi check this..
    1 .the select statement in which the primary and secondary keys are used will gives the good performance .
    2.if the select statement had select up to  i row is good than the select single..
    go to st05 and check the performance..
    regards,
    venkat

  • Count the number of rows resulting from a select statement

    Hi,
    Is there any way of counting the number of rows resulting from a select statement. i.e I have a select distinct statement and I then want to perform an IF statement on the number of rows resulting from the select statement.
    Any help appreciated
    Thanks
    Gary

    Declare
    var1 number;
    Begin
    select count(distinct column_name) into
    var1 from table_name;
    If var1 > x Then
    End IF;
    End;
    Hope I understood the problem correctly
    null

  • PreparedStatement & regular Statement - different results for same select

    I was wondering if someone could either
    i) try this out for me to confirm my results or
    ii) let me know what I am doing wrong
    I'm one of the developers on a product and am currently investigating localization for the Thai language...just checking to see that Java and Swing have no problems with it. The only bewildering thing which has happened is noticing that some values which are fetched from the database display in Thai perfectly and other values display as a garble. Sometimes the exact same column is displayed correctly in one part of the program but is not OK in another part. I think I've figured out what it going on and suspect a bug in Oracle's JDBC:
    Some selects were configured as PreparedStatements and those return the Thai properly. The more common case however was for programmers to use a simple Statement object for their select and it is in those that the multi-byte strings don't get returned properly.
    The following code shows the problem that I am experiencing. I am basically executing the exact same select in 2 different ways and they are both giving different results as long as the column being queried contains a Thai character. If someone could grab and check it out and let me know if they see the same thing, I'd appreciate it. Just change the column/table name and the username/password/databaseIP to get it to run.
    <code>
    import java.sql.*;
    public class SelectTest {
    public static void main(String[] args) {
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@10.4.31.168:1524:ora8",
    "dms_girouard",
    "girouard");
    String sqlCommand = "select C0620_Title from T0620_SwSheet";
    Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    ResultSet resultSet1 = statement.executeQuery(sqlCommand);
    while (resultSet1.next()) {
    if (resultSet1.getString("C0620_Title") != null) {
    System.out.println("resultSet1 Title = " + resultSet1.getString("C0620_Title"));
    PreparedStatement preparedStatement = conn.prepareStatement(sqlCommand);
    ResultSet resultSet2 = preparedStatement.executeQuery();
    while (resultSet2.next()) {
    if (resultSet2.getString("C0620_Title") != null) {
    System.out.println("resultSet2 Title = " + resultSet2.getString("C0620_Title"));
    catch (Exception e) {
    System.out.println(e.getMessage());
    </code>

    Hi Peter,
    Are you using NCHAR column for Thai , or is your database character set set for Thai.
    If you are using a NCHAR column for holding Thai data, then you have to use the
    OraclePreparedStatement.setFormOfUse(...) before executing the select.
    Regards
    Elango. Hi Elangovan,
    Thank you for answering.
    The datatype on the column is VARCHAR2.
    I did my initial tests without doing anything special to make sure the database is localized for Thai, and I was happy to find that almost everything still worked fine - I was able to save and retrieve Thai strings to the database almost perfectly.
    The only problem I discovered was the difference between Statement and PreparedStatement selects on a column containing Thai. Colleagues of mine have said they see the same thing when testing on a Oracle database which has been configured specifically for the Thai customer.
    I read somewhere that the current JDBC drivers are using an older version of the Unicode standard than the most current version of the Java SDK and that it was causing some problems with Korean. I'm wondering if maybe it's the same problem with Thai.

  • "System Resource Exceeded" for simple select query in Access 2013

    Using Access 2013 32-bit on a Windows Server 2008 R2 Enterprise. This computer has
    8 GB of RAM.
    I am getting:
    "System Resource Exceeded"  errors in two different databases
    for simple queries like:
    SELECT FROM .... GROUP BY ...
    UPDATE... SET ... WHERE ...
    I compacted the databases several times, no result. One database size is approx 1 GB, the other one is approx. 600 MB.
    I didn't have any problems in Office 2010
    so I had to revert to this version.
    Please advise.
    Regards,
    M.R.

    Hi Greg. I too am running Access on an RDP server. Checking Task Manager, I can see many copies of MSACCESS running in the process list, from all users on the server. We typically have 40-60 users on that server. I am only changing the Processor Affinity
    for MY copy, and only when I run into this problem. Restarting Access daily, I always get back to multi-processor mode soon thereafter.
    As this problem only seems to happen on very large Access table updates, and as there are only three of us performing those kind of updates, we have good control on who might want to change the affinity setting to solve this problem. However, I
    understand that in other environments this might not be a good solution. In my case, we have 16 processors on the server, so I always take #1, my co-worker here in the US always takes #2, etc. This works for us, and I am only describing it here in case it
    works for someone else.
    The big question in my mind is what multi-threading methods are employed by Microsoft for Access that would cause this problem for very large datasets. Processing time for an update query on, say, 2 million records is massively improved by going down
    to 1 processor. The problem is easily reproduced, and so far I have not seen it in Excel even when working with very large worksheets. Also have not seen it in MS SQL. It is just happening in Access.

  • Can't figure out the correct syntax for this select statement

    Hello,
    The following statement works great and gives the desired results:
    prompt
    prompt Using WITH t
    prompt
    with t as
       select a.proj_id,
              a.proj_start,
              a.proj_end,
              case when (
                         select min(a.proj_start)
                           from v b
                          where (a.proj_start  = b.proj_end)
                            and (a.proj_id    != b.proj_id)
                        is not null then 0 else 1
              end as flag
         from v a
        order by a.proj_start
    select proj_id,
           proj_start,
           proj_end,
           flag,
           -- the following select statement is what I am having a hard time
           -- "duplicating" without using the WITH clause
            select sum(t2.flag)
              from t t2
             where t2.proj_end <= t.proj_end
           ) s
      from t;As an academic exercise I wanted to rewrite the above statement without using the WITH clause, I tried this (among dozens of other tries - I've hit a mental block and can't figure it out):
    prompt
    prompt without with
    prompt
    select c.proj_id,
           c.proj_start,
           c.proj_end,
           c.flag,
           -- This is what I've tried as the equivalent statement but, it is
           -- syntactically incorrect.  What's the correct syntax for what this
           -- statement is intended ?
            select sum(t2.flag)
              from c t2
             where t2.proj_end <= c.proj_end
           ) as proj_grp
      from (
            select a.proj_id,
                   a.proj_start,
                   a.proj_end,
                   case when (
                              select min(a.proj_start)
                                from v b
                               where (a.proj_start  = b.proj_end)
                                 and (a.proj_id    != b.proj_id)
                             is not null then 0 else 1
                   end as flag
              from v a
             order by a.proj_start
           ) c;Thank you for helping, much appreciated.
    John.
    PS: The DDL for the table v used by the above statements is:
    drop table v;
    create table v (
    proj_id         number,
    proj_start      date,
    proj_end        date
    insert into v values
           ( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'),
                to_date('02-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'),
                to_date('03-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'),
                to_date('04-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'),
                to_date('05-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'),
                to_date('07-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'),
                to_date('17-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'),
                to_date('18-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'),
                to_date('19-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'),
                to_date('20-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (10, to_date('21-JAN-2005', 'dd-mon-yyyy'),
                to_date('22-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (11, to_date('26-JAN-2005', 'dd-mon-yyyy'),
                to_date('27-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (12, to_date('27-JAN-2005', 'dd-mon-yyyy'),
                to_date('28-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (13, to_date('28-JAN-2005', 'dd-mon-yyyy'),
                to_date('29-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (14, to_date('29-JAN-2005', 'dd-mon-yyyy'),
                to_date('30-JAN-2005', 'dd-mon-yyyy'));

    Hi, John,
    Not that you asked, but as you proabably know, analytic functions are much better at doing this kind of thing.
    You may be amazed (as I continually am) by how simple and efficient these queries can be.
    For example:
    WITH     got_grp          AS
         SELECT     proj_id, proj_start, proj_end
         ,     proj_end - SUM (proj_end - proj_start) OVER (ORDER BY  proj_start)     AS grp
         FROM     v
    SELECT       ROW_NUMBER () OVER (ORDER BY grp)     AS proj_grp
    ,       MIN (proj_start)                         AS proj_start
    ,       MAX (proj_end)               AS proj_end
    FROM       got_grp
    GROUP BY  grp
    ORDER BY  proj_start
    ;Produces the results you want:
      PROJ_GRP PROJ_START  PROJ_END
             1 01-Jan-2005 05-Jan-2005
             2 06-Jan-2005 07-Jan-2005
             3 16-Jan-2005 20-Jan-2005
             4 21-Jan-2005 22-Jan-2005
             5 26-Jan-2005 30-Jan-2005This is problem is an example of Neighbor-Defined Groups . You want to GROUP BY something that has 5 distinct values, to get the 5 rows above, but there's nothing in the table itself that tells you to which group each row belongs. The groups are not defined by any column in hte table, but by relationships between rows. In this case, a row is in the same group as its neighbor (the row immediatly before or after it when sorted by proj_start or proj_end) if proj_end of the earlier row is the same as proj_start of the later row. That is, there is nothing about 03-Jan-2005 that says the row with proj_id=2 is in the first group, or even that it is in the same group with its neighbor, the row with proj_id=3. Only the relation between those rows, the fact that the earlier row has end_date=03-Jan-2005 and the later row has start_date=03-Jan-2003, that says these neighbors belong to the same group.
    You're figuring out when a new group starts, and then counting how many groups have already started to see to which group each row belongs. That's a prefectly natural procedural way of approaching the problem. But SQL is not a procedural language, and sometimes another approach is much more efficient. In this case, as in many others, a Constant Difference defines the groups. The difference between proj_end (or proj_start, it doesn't matter in this case) and the total duratiojn of the rows up to that date determines a group. The actual value of that difference means nothing to you or anybody else, so I used ROW_NUMBER in the query above to map those distinct values into consecutive integers 1, 2, 3, ... which are a much simpler way to identify the groups.
    Note that the query above only requires one pass through the table, and only requires one sub-query. It does not need a WITH clause; you could easily make got_grp an in-line view.
    If you used analytic functions (LEAD or LAG) to compute flag, and then to compute proj_grp (COUNT or SUM), you would need two sub-queries, one for each analytic function, but you would still only need one pass through the table. Also, those sub-queries could be in-line views; yiou would not need to use a WITH clause.

  • Help with a simple select statement

    $x = oci_parse($c, "select quantity from balance where item_num=101");
    oci_execute($x);
    echo "the quant is: ".$x;
    I try to run this select statement without success
    then I tried...
    $x = oci_parse($c, "select quantity from balance where item_num=101");
    $y= oci_execute($x);
    echo "the quant is: ".$y;
    and it didn't work either...
    What should I change?
    thanks!

    The Oracle library operates a bit differently from some other PHP libraries, notably MySQL/MySQLi. With Oracle (OCI8), you have to execute the statement, and then afterward use an oci_fetch...() function to pull things from your $statement variable. Here's a small example that hopefully will illustrate the basic usage:
    <?php
         $conn = oci_connect('hr','hr','xe');
         if(!$conn) {
              echo 'Could not connect!';
              exit;
         $sql = 'select * from jobs';
         $stmt = oci_parse($conn, $sql);
         if(!$stmt) {
              echo 'Could not parse query.';
              exit;
         $result = oci_execute($stmt, OCI_DEFAULT);
         if(!$result) {
              echo 'Could not execute query.';
              exit;
         echo "Query ran successfully.\n";
         // Fetch rows as associative arrays, so
         // we can ask for values by column name.
         // Other options include oci_fetch_row(),
         // oci_fetch_array(), and oci_fetch_object().
         // Note that oci_fetch_assoc() will create
         // an associative array using upper-case
         // column names for the keys.
         while(($row = oci_fetch_assoc($stmt)) != null)
              echo $row['JOB_ID'] . ': ' . $row['JOB_TITLE'] . "\n";
         echo "All data returned.\n";
         oci_close($conn);
    ?>When I run this, I get the following:
    C:\workspace\php>php select.php
    Query ran successfully.
    AD_PRES: President
    AD_VP: Administration Vice President
    AD_ASST: Administration Assistant
    FI_MGR: Finance Manager
    FI_ACCOUNT: Accountant
    AC_MGR: Accounting Manager
    AC_ACCOUNT: Public Accountant
    SA_MAN: Sales Manager
    SA_REP: Sales Representative
    PU_MAN: Purchasing Manager
    PU_CLERK: Purchasing Clerk
    ST_MAN: Stock Manager
    ST_CLERK: Stock Clerk
    SH_CLERK: Shipping Clerk
    IT_PROG: Programmer
    MK_MAN: Marketing Manager
    MK_REP: Marketing Representative
    HR_REP: Human Resources Representative
    PR_REP: Public Relations Representative
    All data returned.
    C:\workspace\php>For more information, take a look at the OCI8 library documentation in the PHP manual online:
    OCI8
    http://us.php.net/manual/en/book.oci8.php
    Some other examples
    http://us.php.net/manual/en/oci8.examples.php
    Kind regards,
    Christopher L. Simons

  • Query regarding Oracle SQL select statement

    Hi,
    How does Oracle ensures a consistent snapshot with the select statement
    without locking the table. My question is summarized with an example below:
    1. At time T1, Oracle select statement is fired and is fetching the result.
    2. At time T2, some DML operation is performed on the same table on which
    the select was executed and a commit was fired.
    3. At time T3, The Oracle select statement (Step 1) completes.
    My question is whether the records of transaction at time T2 will be visible at time T3 or not?
    If "not", then does it mean that Oracle retrieves the rows from the time of last commit.
    I would also like to know if for the above mechanism, Oracle would make use of the rollback segemt to access the rows at a particular instant of time.
    TIA
    Regards,
    Raj

    This is called Read Consistency in the oracle. Its all about SCN before starting the transaction.
    Lets say
    1. T1 executs SELECT statement on EMP table.
    2. T2 made an update on the EMP and commited.
    But, T1 only still sees only old image of the data not the new one. This is called read consistency.
    You will be having two images in the buffer, one is consistent and changed image.
    When the T1 give SELECT statement it notes the SCN of the transaction. Read oracle document about read consistency.
    SJH.

  • How to JOIN the results of multiple SELECT statements

    Hello,
    I currently have a table where each row represents a single census date for a given tag number, where each tag number can have multiple census dates and data which are represented by their own row in the table.
    I currently have 2 SELECT statements that select all tag numbers given a census date, and would like to combine those 2 queries so that the data is presented in a manner such that for each tag number, instead of obtaining 2 rows for each tag number, I would be presented with 1 row for each tag number consisting of three columns: tag_number, data1, and data2.
    Both of the requested dates are not necessarily present for all tag numbers, and in the event that only one date is present, the other column should contain null, but if both dates are not present for a given tag number, the tag number is omitted.
    The two queries I would like to JOIN are:
    SELECT a.tag_number, a.data AS data1
    FROM tab1 a
    WHERE
    a.census_date='11/21/2009'and
    SELECT b.tag_number, b.data AS data2
    FROM tab2 b
    WHERE
    b.census_date='11/24/2009'The table from which I am selecting the data looks like such:
    tag_number  census_date     data
        1       11/21/2009      10
        1       11/23/2009      11
        1       11/24/2009      12
        2       11/19/2009      13
        2       11/21/2009      14And the data that I would like to result looks like:
    tag_number  data1           data2
        1       10              12
        2       14              nullAny help would be greatly appreciated.
    Thank you in advance,
    -Justin
    Edited by: m8r-qbkka9 on Nov 24, 2009 4:17 PM

    Hi,
    This looks like a job for pivot
    SELECT       a.tag_number
    ,       MAX (CASE  WHEN a.census_date = TO_DATE ('11/21/2009'
                                                       'MM/DD/YYYY'
                   THEN a.data
                END
               )          AS data1
    ,       MAX (CASE  WHEN a.census_date = TO_DATE ('11/24/2009'
                                                       'MM/DD/YYYY'
                   THEN a.data
                END
               )          AS data2
    FROM      tab1    a
    WHERE       a.census_date  IN ( TO_DATE ( '11/21/2009'
                                      , 'MM/DD/YYYY'
                       , TO_DATE ( '11/21/2009'
                                      , 'MM/DD/YYYY'
    GROUP BY  a.tag_number
    ;Comparing DATEs to stirngs, like '11/24/2009', is simply asking for trouble.
    Always use a conversion function (like TO_DATE) or DATE literals instead.

  • Interpretation of query results (one simple example)

    Hi Gurus,
    I have one question about the interpretation of query results. Especially for columns and when they are changed / moved in order within the BEx Analyzer.
    For example I have the following columns:
    Characteristics:
    Credit control Area
    Company code
    Sales Division
    Calendar/Month
    Key figures:
    Turn over
    Revenue.
    This interpretation would be from my point of view as follows:
    Turnover and Revenue by Credit control Area, Company code, Sales Division and Calendar/Month.
    If the characteristics are changed in order for example like this:
    Characteristics:
    Credit control Area
    Calendar/Month
    Sales Division
    Company code
    Key figures:
    Turn over
    Revenue.
    The interpretation should be the same and only the displaying/ grouping of results/ characteristics would change?
    Turnover and Revenue by Credit control Area, Company code, Sales Division and Calendar/Month.
    Thanks in advance!

    Ok, this means if you remove one characteristic for example "Company code", the characteristic "stays" in the background and the values are still the same (for the current selection). Only the appearrance (grouping) is different because one characteristic is less.
    If you ad new values, for example additional company codes, of course the values like summation are changing (summarized).

  • How do I return the results of two SELECT statements in to one result?

    I want to do this without using UNION.
    Here's an example of what I'm trying to do:
    I have a table called COUNTRY with the following columns:
    COUNTRY
    COUNTRY_CODE
    DATE_VISITED_LAST
    POPULATIONI have another table called STATE_COUNTY with the following columns:
    STATE_COUNTY
    COUNTRY_CODE
    STATE_COUNTY_CODE
    DATE_LAST_VISITED
    POPULATIONI have a third table called TOWN with the following columns:
    TOWN
    COUNTRY_CODE
    STATE_COUNTY_CODE
    TOWN_CODE
    DATE_LAST_VISITED
    POPULATIONNow through the interface I have, a user will supply a country code. I need a SELECT statement that will return a table with the following result set:
    The COUNTRY_CODE entered including the DATE_LAST_VISITED and POPULATION for this country
    ------> All the associated STATE_COUNTY's belonging to this country along with the DATE_LAST_VISITED and POPULATION for each STATE_COUNTY_CODE.
    -------------> All the associated TOWN_CODE's belonging to this state_county and country along with the DATE_LAST_VISITED and population for each TOWN.
    So the table will have 9 columns:
    COUNTRY
    DATE_LAST_VISITED_COUNTRY
    POPULATION_COUNTRY
    STATE_COUNTY
    DATE_LAST_VISITED_STATE_COUNTY
    POPULATION_COUNTY
    TOWN
    DATE_LAST_VISITED_TOWN
    POPULATION_TOWNAny ideas how this can be done?
    Thanks.

    Hi guys,
    Would it be ok to do it like this (with a join):
    SELECT      
         c.country_code,
         c.date_last_visited AS DATE_LAST_VISITED_COUNTRY,
         c.population AS POPULATION_COUNTRY,
         s.state_county_code,
         s.date_last_visited AS DATE_LAST_VISITED_STATE_COUNTY,
         s.population AS POPULATION_COUNTY,
         t.town_code,
         t.date_last_visited AS DATE_LAST_VISITED_TOWN,
         t.population POPULATION_TOWN,
    FROM
         country c
         LEFT OUTER JOIN state_county s ON s.country_code = c.country_code
         LEFT OUTER JOIN town       t ON t.country_code = s.country_code
    AND                                       t.state_county_code = s.state_county_codeThe results required would be something like:
    Country_Code     DATE_LAST_VISITED_COUNTRY     POPULATION_COUNTRY     STATE_COUNTY_CODE         DATE_LAST_VISITED_STATE_COUNTY         POPULATION_COUNTY     TOWN_CODE     DATE_LAST_VISITED_TOWN     POPULATION_TOWN
    UK               14-JAN-09                     56,00000               London                    18-JUL-99                              23,0000               Ascot         30-JUN-89                  12,000
                                                                                                                                                                 Brixton       28-JAN-92                  4,684
                                                                          Birmingham                12-SEP-09                              55,678                Solihull      12-OCT-81                  6.768 Does this make sense?
    Thanks!
    Edited by: Sastry on Nov 2, 2009 2:04 AM

  • Fetching query result for editbox

    Hello to everyone. I just started developing Windows application (after 2 years pause). So, I'm working 'with' MFC Dialog based app.
    I want to fill combo box (or edit box it doesn't matter) with MySQL query result. I have these codes:
    void CConnectToMySQLDlg::OnWriteToDatabase()
    CString get, set;
    m_edit.GetWindowText(get);
    CT2CA temp_string(get);
    string s_get(temp_string);
    if (m_edit.GetWindowTextLength() != 0) // if you can please write this line better.
    MySQL_Driver *driver;
    Connection *dbConn;
    Statement *statement;
    ResultSet *result;
    driver = get_mysql_driver_instance();
    dbConn = driver->connect("tcp://127.0.0.1:3306", "root", "connection");
    dbConn->setSchema("world");
    statement = dbConn->createStatement();
    result = statement->executeQuery(s_get);
    //CStringArray comboArray;
    /*comboArray.Add(_T("bir"));
    comboArray.Add(_T("iki"));
    comboArray.Add(_T("uc"));
    comboArray.Add(_T("dord"));
    comboArray.Add(_T("bes"));
    comboArray.Add(_T("ffsfsfs"));
    comboArray.Add(_T("bfsfsfsdes"));
    comboArray.Add(_T("bczxczxes"));
    comboArray.Add(_T("aadafdsbes"));
    comboArray.Add(_T("zczxawfebes"));*/
    //comboMysql.ResetContent();
    string s_set = "string";
    set.Format(_T("%S"), s_set.c_str());
    while (result->next())
    // here how can I set edit box value?
    // So, how can I convert
    AfxMessageBox(L"dsadasd");
    delete result;
    delete statement;
    delete dbConn;
    else // handling user input
    AfxMessageBox(L"not allowed");
    I can get input stream and successfully(1) execute it but I don't know how to set its result(s).
    (1) --- In this case I entered this SQL line:
    select ID, Name from city where ID = 1 or ID = 2 or ID = 3 or ID = 4
    and it alerted me 4 times.
    p.s. If there any problematic codes please tell me the correct variant(s).
    Best regards,
    Mirjalal.

    I solved my problem. I pasted working codes below.
    void CmysqlDlg::OnBnClickedButton1()
    CString get, set, ComboString;
    edit.GetWindowText(get);
    CT2CA temp_string(get);
    std::string s_get(temp_string);
    if (edit.GetWindowTextLength() != 0) // if you can please write this line better.
    MySQL_Driver *driver;
    Connection *dbConn;
    Statement *statement;
    ResultSet *result;
    driver = get_mysql_driver_instance();
    dbConn = driver->connect("tcp://127.0.0.1:3306", "root", "connection");
    dbConn->setSchema("world");
    statement = dbConn->createStatement();
    result = statement->executeQuery(s_get); // executes the user "input"
    comboBox.ResetContent();
    // ofstream y("text.txt"); // actually i don't need this anymore :P
    while (result->next())
    string name_string = result->getString("Name"); // Name is the my tbl column name
    CString cs_name_string(name_string.c_str());
    comboBox.AddString(cs_name_string);
    delete result;
    delete[] result;
    delete statement;
    delete[] statement;
    delete dbConn;
    delete[] dbConn;
    else // handling user input
    AfxMessageBox(L"olmaz");
    Thanks.
    Mirjalal

Maybe you are looking for

  • Error in running a z report

    Hi We have developed a Z-report for preparing summery of all drawings for a project. This report is working fine in one user id but it is showing error in other user id showin that incorrect date is entered How can this possible? What should be done?

  • Getting error when trying to login to CR XI server on suse linux server

    http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_21747694.html Hello, I'm getting the above error when I try to login as administrator (blank password). This did work until I rebooted the linux server. I checked there are no port

  • Installing SSD in GT60 Dominator

    Hi, I just picked up a new GT60 Dominator 3K Edition. The laptop did not come with an SSD installed, though I had a 240GB SSD from my old laptop, and I would love to be able to shift the OS over to the SSD and use the 1TB drive just for data and a fe

  • QuickTime Pro: Audio Settings disabled

    I'm trying to add background music to a video in QT, and need to lower the volume so it doesn't drown out the narration. Went into Properties, clicked on "Audio Settings" & none of the options will do anything. Everything's either grayed out or unres

  • Can't take off credit card from itunes store and 'none' is not an option

    I need help taking off my credit card from itunes and when i edit payment options 'none' is not an option what do i do?