Worn and counting on the same query?

I have a table with the following fields: groupname, FULL_NAME, DEFAULT_X, SUPPORT_GROUP_ID and PERSON_ID (among others)
A user (PERSON_ID) can be different times, they appear once for each group (SUPPORT_GROUP_ID) that they are assigned to.
When the DEFAULT_X == 0, this means that the user's default group is on this line. Each user should have only one only by default the group, but for some reason, the table was corrupted and there are a few users that don't have a default group.
What I'm trying to do is to select all the users (FULL_NAME, PERSON_ID) where the PERSON_ID COUNTY is equal to the SUM of DEFAULT_X
It sounds easy enough, but I don't even know where to start.
Any suggestions?

Hello

So you say
default_x = 0 if this is the default group, and
default_x = 1 in all other cases
Is this fair?

If so, you can say:

SELECT    person_id
FROM      table_x
GROUP BY  person_id
HAVING    COUNT (*) = SUM (default_x);

HAVING is similar to WHERE, except that HAVING is applied after the merger took place and functions of aggregation (like SUM and COUNT) were calculated.

However, your problem is that default_x is not entered correctly. If default_x is sometimes 1 to 0, are not concerned it may contain other errors, like having 2 or - 1, whereas she would have to have 1?

Here's a better way to find person_id who don't exactly have a single line with default_x = 0:

SELECT    person_id
FROM      table_x
GROUP BY  person_id
HAVING    SUM
          (
              CASE
                  WHEN  default_x = 0
                  THEN  1
                  ELSE  0
              END
          ) != 1;

Tags: Database

Similar Questions

  • Group by and count on the same table

    Hello

    DB version: 11.2.0.3

    Tried to SQL:

    create table log1 (identification number, status varchar2 (15) date of insert1);

    insert into log1 values (1, 'SUCCESS', sysdate-1);

    insert into log1 values (2, 'SUCCESS', sysdate-2);

    insert into log1 values (3, 'FAIL', sysdate-1);

    insert into log1 values (4, 'FAIL', sysdate-2);

    insert into log1 values (5, 'FAIL', sysdate-1);

    insert into log1 values (6, 'ERROR', sysdate-1);

    insert into log1 values (7, 'ERROR', sysdate-1);

    insert into log1 values (8, 'ERROR', sysdate-1);

    insert into log1 values (9, 'ERROR', sysdate-1);

    WITH AS TBL1

    (SELECT THE STATE OF 'SUCCESS' OF THE DUAL UNION ALL

    SELECT "FAIL" STATUS OF THE DUAL UNION ALL

    SELECT 'PENDING' STATUS OF DOUBLE)

    SELECT NVL (TBL1. STATUS OF STATE, 'TOTAL'), COUNT (LOG1.ID)

    FROM TBL1 JOIN LOG1 FULL EXTERNAL

    ON LOG1. STATUS = TBL1. STATUS

    GROUP BY ROLLUP (TBL1. STATUS)

    STATUSCOUNT (LOG1.ID)
    IN CASE OF FAILURE3
    SUCCESS2
    PENDING0
    TOTAL (*)4
    TOTAL9

    t need only State of SUCCESS, FAILURE, WAITING. and NUMBER of global ID omit the rest of type status as ERROR, etc. EXECUTION in the result set.

    I don't need the TOTAL (*) of the above result set. Which is total (Error).

    Please tell us how the query above can be changed to produce the result to wait.

    Thank you

    Hello

    So, you want to see all the tbl1 lines, if they have a match in log1, and for the grand total of lines, you must count the log1 lines if they have a match with tbl1.  This looks like a job for a FULL OUTER JOIN:

    SELECT t.status

    EARL of (l.status) AS cnt

    OF log1 l

    FULL OUTER JOIN tbl1 t WE t.status = l.status

    GROUP OF ROLLUP (t.status)

    HAVING t.status IS NOT NULL

    OR of a GROUP (t.status) = 1

    ;

  • With the help of lag and grade in the same query

    Hello

    I'm trying to find out the time difference between the memberships peoples, as well as the order in which these memberships are in. So far, I have added in a release status of work on the order, in that the accessions were created, but now want to look at the difference between the dates returned. The SQL, I used is:

    SELECT owner_party_id,
    mem_number,
    support_id,
    mem_start_date,
    Rank() over (PARTITION BY owner_party_id ORDER BY mem_start_date ASC) MEMBERSHIP_SEQUENCE
    OF membership_all
    WHERE version_type = "NEWS".
    AND owner_party_id IN ('65051', '65051', '65348', '65348', '65607' 65607', 65607')

    to get:

    "OWNER_PARTY_ID" | "' MEM_NUMBER ' | "' SUPPORT_ID ' | "' MEM_START_DATE ' | "" MEMBERSHIP_SEQUENCE ".
    65051 | 318874751 | 8014747 | 1ST MARCH 10 | 1
    65051 | 412311060 | 21502883 | 15 AUGUST 12 | 2
    65348 | 308672459 | 3526913 | MAY 1, 10. 1
    65348 | 409951130 | 20950524 | 18 JUNE 12 | 2
    65607 | 315830192 | 7510133 | MAY 17, 10 | 1
    65607 | 406448110 | 20024246 | MARCH 16, 12. 2
    65607 | 409738130 | 20903556 | JUNE 14, 12. 3

    Now I want to calculate the difference between the starting dates of each of the groups owner_party_id, in order to get something like this:

    OWNER_PARTY_ID | MEM_NUMBER | SUPPORT_ID | MEM_START_DATE | MEMBERSHIP_SEQUENCE | Diff
    65051 | 318874751 | 8014747 | 1st March 10 | 1.
    65051 | 412311060 | 21502883 | 15 August 12 | 2. 898
    65348 | 308672459 | 3526913 | May 1, 10. 1
    65348 | 409951130 | 20950524 | 18 June 12 | 2. 779
    65607 | 315830192 | 7510133 | May 17, 10 | 1
    65607 | 406448110 | 20024246 | March 16, 12. 2. 669
    65607 | 409738130 | 20903556 | June 14, 12. 3. 90

    I think I need to use the Lag function, but I'm not sure if it can be linkited looking at the data within a group id of owner of party, that it would be foolish to calculate the difference in dates for the two different owner group ID.

    Any advice much appreciated.

    Thank you

    Published by: 992871 on March 9, 2013 23:34

    Maybe NOT TESTED!

    SELECT owner_party_id,
           mem_number,
           support_id,
           mem_start_date,
           RANK() OVER (PARTITION BY owner_party_id ORDER BY mem_start_date) MEMBERSHIP_SEQUENCE,
           mem_start_date - LAG(mem_start_date,1) OVER (PARTITION BY owner_party_id ORDER BY mem_start_date) diff
      FROM membership_all
     WHERE version_type = 'CUR'
       AND owner_party_id IN ('65051','65051','65348','65348','65607','65607','65607')
    

    Concerning

    Etbin

  • Min and Max in the same query

    Hi all
    Please help me to write the query to the following data
    s_max dated s_min
    --------------------------------------------------------
    627 627 1 April 2010 00:00
    628 628 April 1, 2010 02:00
    629 629 April 1, 2010 04:00
    630 630 April 1, 2010 06:00
    631 631 April 1, 2010 08:00
    632 632 April 1, 2010 10:00
    633 633 April 1, 2010 12:00
    634 634 April 1, 2010 14:00
    635 635 April 1, 2010 16:00
    636 636 1 April 2010 18:00
    637 637 1 April 2010 20:00
    638 638 1 April 2010 22:00
    639 639 2 April 2010 00:00
    640 640 April 2, 2010 02:00
    641 641 April 2, 2010 04:00

    I want to ouput as follows
    s_max dated s_min
    --------------------------------------------------------
    627 638 1 April 2010 22:00
    639-641 April 2, 2010 04:00

    appreicate your help.

    Concerning
    Mir.

    You do not follow Boniest.

    Just run this part-

    select min(smin) smin, max(smax) smax, max(datee) datee
    from   my_tab
    group by trunc(datee);
    

    It will work for you.

    Given that you provide any data script or table - it must prepare for you to test the result.

    Kind regards.

    LOULOU.

  • Determine the maximum length of a column and its use in the same query?

    I would like to determine the maximum length of a column and use it in the same query. Is this possible? IE:

    SELECT RPAD (last_name, SELECT MAX (LENGTH (last_name)) + 5 FROM user, '-')
    OF the user.

    Thank you

    Hello

    Welcome to the forum!

    jfraley wrote:
    I would like to determine the maximum length of a column and use it in the same query. Is this possible? IE:

    SELECT RPAD (last_name, SELECT MAX (LENGTH (last_name)) + 5 FROM user, '-')
    OF the user.

    Thank you

    Sure. You almost go in your message: a scalar subquery . Just put brackets around the subquery:

    SELECT      RPAD ( last_name
              , (
                 SELECT  MAX (LENGTH (last_name)) + 5
                 FROM    user_tbl          -- USER is not a good table name
                )
              , '-'
              )          AS padded_last_name
    FROM      user_tbl
    ;
    

    Scalar subqueries in SQL are like tape in your garage in canvas: they are used for thousands of different things and open, maybe 1% of them. Usually, there are better ways to achieve the same results, such as the analytical functions:

    SELECT      RPAD ( last_name
              , 5 + MAX (LENGTH (last_name)) OVER ()
              , '-'
              )          AS padded_last_name
    FROM      user_tbl
    ;
    

    Still another way is to make the subquery and then join his game as if it were a table of results:

    WITH     got_max_length     AS
    (
         SELECT     MAX (LENGTH (last_name))     AS max_length
         FROM     user_tbl
    )
    SELECT      RPAD ( u.last_name
              , m.max_length + 5
              , '-'
              )          AS padded_last_name
    FROM           user_tbl     u
    CROSS JOIN     got_max_length     m
    ;
    

    Published by: Frank Kulash, December 12, 2011 21:17
    Added cross join example

  • Avoid using the same query...

    How can I avoid to use the same query again and again using a single query, such as

    SELECT
    a,
    b * (SELECT COUNT (C1) FROM T2);
    c * (SELECT COUNT (C1) FROM T2);
    d * (SELECT COUNT (C1) FROM T2)
    Of
    T1;

    Fanny says:
    How can I avoid to use the same query again and again using a single query, such as

    SELECT
    a,
    b * (SELECT COUNT (C1) FROM T2);
    c * (SELECT COUNT (C1) FROM T2);
    d * (SELECT COUNT (C1) FROM T2)
    Of
    T1;

    A few cross join?

    select a, b*cnt, c*cnt, d*cnt
      from t1, (select count(c1) cnt from t2)
    
  • Request of MSN Games I want to play Spades with my friends, I know personally, and also at the same time, they are online in MSN Games.

    Original title: query MSN games

    I play generally stings in MSN Games. I play with these opponents, who are are the corresponding animation.

    But suppose I want to play Spades with my friends, I know personally, and also at the same time, they are online in MSN Games.

    Is there a way I can do?

    Yes ReCkle$ $ there is a way

    because deleted msn games this option of Spades online, u do not have the section 'invite' as b4, you will need to:

    (1) you and your partner open Spades and click on the 'standard' at the same time game. After a 1 ~ 5 try u should be and your friend partner at the same table.

    * your 'level' and your partners must be close to u at the same table.

    Hope this helps :)

  • How to use headphones and speakers at the same time

    I want to use headphones at the same time that I use the speakers.

    I am hard of hearing and need the LOUD volume. When others are watching a film, projected on HDTV, they won't let me turn the volume up to where I need it, which is why, headphones and speakers at the same time.

    I use Windows 7, I want to stick with Windows 7, so I want a Windows 7 solution.

    If there is no solution for Windows 7 and there is a solution using Windows 10, then and then only, I will be upgrading to Windows 10.

    Using headphones and speakers was possible under Windows XP. I think that a kid at Microsoft, with a regular audience, thought this feature was redundant and removed. Large.

    Macs will play through the headphones and speakers, so maybe it's time to buy a Mac!

    Hi Bob,

    Thanks for posting your query on the Microsoft Community.

    With the description, I understand that you want to use headphones and speakers at the same time on your Windows 7 computer. I will certainly help you get this fixed number.

    I suggest you check the suggestions contained in below mentioned thread and check if this is useful:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-pictures/headphones-speakers-at-the-same-time/7ed31bcf-3762-430D-9c9f-e6967d670d0e

    Hope this information is useful. Please come back to write to us if you need more help, we will be happy to help you.

  • Unable to connect to the TIME WAN and WIFI at the same time

    Hello

    Here's the situation - I'm setting up a mobile registration system that uses the remote wireless via a router dedicated to the sound system.

    I use the router on the PA system to remotely control my mixer and software only on the cable network.   The wireless network is used to communicate with the internet and send audio files between my workshop and the meeting place during a broadcast so that the engineer can have a production finished execution until the crowd clears, so the band can sell a CD of the show.   There is no use between the two networks and they need to run independently of the other.

    I'm having a problem where network connections will only be activated at any time.   I need to have the wired adapter and adapter wireless running at the same time.

    I'm good on the sound equipment, but know little about networks and computers.  I am open to suggestions or advice.   A procedure step by step on how to do that would be nice (as a network for Dummies!  (LOL).

    I am at a loss to know where to start, so any help would be appreciated.

    Thank you.

    Lequarius

    Hello


    Thanks for posting in the Microsoft Community.

    We have a dedicated team with advanced tools and permission to help with this issue. Then I suggest you to report the same query in TechNet forum.
    https://social.technet.Microsoft.com/forums/Windows/en-us/home?category=w7itpro

    Thank you.
  • WebVPN and anyconnect on the same interface

    Hello!!

    We have ASA 5520 firewall running with code.9.1 (2). We already have webvpn running on the firewall and has active users to use it. Now, the client came with a new requirement to configure firewalls on the same anyconnect. We have installed VPN more premium license.

    (1) is it possible to enable webvpn and anyconnect on the same interface. If Yes, what are the aspects we must consider to allow them both on the same interface?

    (2) how much webvpn and anyconnect vpn licenses should I do with my premium lincense?

    Please help on this.

    shver attached for reference.

    Best regards

    Sri

    Your peers licenses AnyConnect Premium gives you the right to access SSL VPN without customer and focused on the customer.

    Licensing is based on the concurrent users so regardless of the simultaneous dosing will work - as long as the number of connected does not exceed 100.

    Your site to site VPN IPsec does not count against this permission, but is rather against "Other peer VPNS" which does not require a separate license and is limited by the capacity of the ASA equipment (750 on your platform).

  • Why I have two different execution plans for the same query on two different servers

    Hello everyone.

    I need your help to solve the problem quickly.

    In a nutshell, we have two servers that have the same version of Oracle RDBMS (11.2.0.4 EE). One of them for purposes of development and another is a production one.

    We have therefore two different execution plans for the same query executed on both servers. The only case of execution is OK and another is too slow.

    So I have to slow down the work of query using the same scheme to explain that young.

    Fence wire.

  • Detailed form Master in Apex - creating main records and details at the same time

    I m trying to create a master form / retail.
    The master is a simple standard form and below on the same page there is a tabular presentation containing the details.

    I am facing a problem when you try to save a new record from the master at the same time with new details.
    If I create a new record of the master and at the same time create detail records for this master (on the same page), when I submit that the foreign key of the details field is not filled in. So only one master record gets inserted into the table and record line is not inserted.

    When I have everything first create a master without a detail and edit this master and then add details so everything's allright (since the primary key field is filled out at the time).

    I just need to confirm that whether in the APEX form master detail, can save master and line record at the same time or is it as master must be registered the 1 and then line must be enterd and saved?

    Please let me know, if this functionality can be achieved in the APEX.

    Hello

    There was an error in the process of pl/sql, you referenced f01 (F01. COUNT) in the loop condition and which should have been f03, also you have assigned the wrong field to what should have been P3_DEPARTMENT_ID

    I fixed that. Also, I'm not 100% sure but I think in order to use the table in the column must be of type text or something (and not hidden), but I can't check now because of lack of time.

    A few mistakes during the presentation, but they are still due to constraints on the other fields.

    FOR I IN 1.APEX_APPLICATION. G_F03. COUNTY

    LOOP

    APEX_APPLICATION. G_F03 (I): =: P3_DEPARTMENT_ID;

    END LOOP;

    Concerning

    Bottom

  • explain plan for the same query diff

    Hi experts,

    Please, help me understand explain the plan.  I have tow Server (server and two server). The server are same table, even the type of database, even version Oracle (gr 11 (2), same operating system (linux Redhat 5.5) and same table and index.

    but when I explain the plan for the same query on the two server. I got diff--diff to explain the plan. reason it has different, according to my understanding, it should be same. explain please, I share the explain plan and lower indices for the two server.

    Server a

    SQL > col COLUMN_NAME format a20

    SQL > select index_name, column_name, position_colonne from user_ind_columns where table_name = 'LOAN_RUNNING_DETAILS_SOUTH"of order 1.

    INDEX_NAME COLUMN_NAME POSITION_COLONNE

    ------------------------------ -------------------- ---------------

    DATE_IND1_S LOANDATETIME 1

    IND_MSI_LN_LNS1_S MSISDN 1

    IND_MSI_LN_LNS1_S LOANDATETIME 2

    IND_MSI_LN_LNS1_S LOANSTATUS 3

    LAST_INDEX L_INDX_MSISDN_S 1

    MSISDN L_INDX_MSISDN_S 2

    SQL > select decode (status, 'N/a', 'Part Hdr', 'Global') ind_type, index_name, NULL nom_partition, status

    2 from user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH '.

    3 union

    4. Select 'Local' ind_type, index_name, nom_partition, status

    5 to user_ind_partitions where index-name in (select index_name in user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH')

    6 order of 1,2,3;

    IND_TYPE INDEX_NAME NOM_PARTITION STATUS

    -------- ------------------------------ ------------------------------ --------

    Global DATE_IND1_S VALID

    Global IND_MSI_LN_LNS1_S VALID

    Global L_INDX_MSISDN_S VALID

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME < = sysdate-2 and LOANDATETIME > sysdate-15 and LOANTYPE = 1;

    He explained.

    SQL > SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 3659874059

    ------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |  1448K |    58 M | 21973 (2) | 00:04:24 |       |       |

    |*  1 |  FILTER |                            |       |       |            |          |       |       |

    |   2.   PARTITION LIST ALL |                            |  1448K |    58 M | 21973 (2) | 00:04:24 |     1.    11.

    |*  3 |    TABLE ACCESS FULL | LOAN_RUNNING_DETAILS_SOUTH |  1448K |    58 M | 21973 (2) | 00:04:24 |     1.    11.

    ------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    3 - filter("LOANTYPE"=1 AND "LOANDATETIME">SYSDATE@!-15 AND "LOANDATETIME"<=SYSDATE@!-2)

    16 selected lines.

    Second server

    SQL > select index_name, column_name, position_colonne from user_ind_columns where table_name = 'LOAN_RUNNING_DETAILS_SOUTH"of order 1.

    INDEX_NAME COLUMN_NAME POSITION_COLONNE

    ------------------------------ -------------------- ---------------

    DATE_IND1_S LOANDATETIME 1

    IND_MSI_LN_LNS1_S MSISDN 1

    IND_MSI_LN_LNS1_S LOANDATETIME 2

    IND_MSI_LN_LNS1_S LOANSTATUS 3

    LAST_INDEX L_INDX_MSISDN_S 1

    MSISDN L_INDX_MSISDN_S 2

    SQL > select decode (status, 'N/a', 'Part Hdr', 'Global') ind_type, index_name, NULL nom_partition, status

    2 from user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH '.

    Union

    3 4 Select 'Local' ind_type, index_name, nom_partition, status

    5 to user_ind_partitions where index-name in (select index_name in user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH')

    6 order of 1,2,3;

    IND_TYPE INDEX_NAME NOM_PARTITION STATUS

    -------- ------------------------------ ------------------------------ --------

    Global DATE_IND1_S VALID

    Global IND_MSI_LN_LNS1_S VALID

    Global L_INDX_MSISDN_S VALID

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME < = sysdate-2 and LOANDATETIME > sysdate-15 and LOANTYPE = 1;

    SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 1161680601

    ----------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ----------------------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |     2.    84.     5 (0) | 00:00:01 |       |       |

    |*  1 |  FILTER                             |                            |       |       |            |          |       |       |

    |*  2 |   TABLE ACCESS BY INDEX ROWID | LOAN_RUNNING_DETAILS_SOUTH |     2.    84.     5 (0) | 00:00:01 | ROWID | ROWID |

    |*  3 |    INDEX RANGE SCAN | DATE_IND1_S |     2.       |     3 (0) | 00:00:01 |       |       |

    ----------------------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    2 - filter ("LOANTYPE" = 1)

    3 - access("LOANDATETIME">SYSDATE@!-15 AND "LOANDATETIME"<=SYSDATE@!-2)

    17 selected lines.

    Reg,

    Hard

    Hi , HemantKChitale,

    I also update statistics manual as you say, but not see 'TABLE ACCESS FULL' good result

    What should I do? my need of production tuning, but I cannot able tune this...

    SQL > exec dbms_stats.gather_table_stats (-online 'ttt' ownname, tabname => 'LOAN_RUNNING_DETAILS_SOUTH', cascade => TRUE, estimate_percent => NULL, method_opt => 'for all columns size 254', => of degree 4);

    PL/SQL procedure successfully completed.

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME<=sysdate-2 and="" loandatetime="">sysdate-15 and LOANTYPE = 1;

    He explained.

    SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 3659874059

    ------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |  1874K |    75 M | 19626 (2) | 00:03:56 |       |       |

    |*  1 |  FILTER |                            |       |       |            |          |       |       |

    |   2.   PARTITION LIST ALL |                            |  1874K |    75 M | 19626 (2) | 00:03:56 |     1.    11.

    |*  3 |    TABLE ACCESS FULL | LOAN_RUNNING_DETAILS_SOUTH |  1874K |    75 M | 19626 (2) | 00:03:56 |     1.    11.

    ------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    3 - filter("LOANDATETIME">SYSDATE@!-15 AND "LOANTYPE"=1 AND "LOANDATETIME")<>

    16 selected lines.

  • I use the same query in two difference db (exp/imp) but run different times!

    Hello

    I have 2 database. One of the remote server, one at my local. I used exp/imp to retrieve data from remote to my local database. Structers, tables and indexes is the same.
    My local machine is more powerful than the remote computer. (Ram, cpu County ext)

    But when I connect remotely from my local computer, this application runs 4 second (with view). But when I connect to my local db, this query run 5 minutes.
    Number of rows returned is 18,500

    What's wrong? Why get the bytes of the value are different?

    Local explain plan is:
    SELECT STATEMENT ALL_ROWS Cost: 203 Bytes: 19,062,160 Cardinality: 18,329                                         
    Remote control explain plan is:
    SELECT STATEMENT ALL_ROWS Cost: 226 Bytes: 3,855,214 Cardinality: 18,446                                         
    My plans to explain (remote and the) and other (auto track, oracle params) data is in excel file (because of this forum not to accept more than 30,000 words);

    http://www.eksicevap.com/tech/explainplan.xls
    for winrar:
    http://www.eksicevap.com/tech/explainplan.rar

    Thanks for help

    Oracel version information:
    Local:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    Distance:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi

    Published by: Melike on 15.Mar.2011 02:42

    Published by: Melike on 15.Mar.2011 03:39

    Melike says:
    Thanks, Johan, I'll try.
    My first post for local oracle param, I got it 3 days ago. or I confuse my file params to oracle. (This problem continues from last week)
    Now I'm waiting still current oracle local params and these value is worse:

    Local:
    pga_aggregate_target 0
    SGA_MAX_SIZE 536.870.912
    SGA_TARGET 0

    I update the new oracle local params in my previous message.

    I'll try the update of these values, but I hope, my local oracle is not drop down :)

    Can't be worse...
    You have a parameter memory_target (and max_memory_target)? If so, you could add memory to these settings as well and only set pga_aggregate_target (no CMS or sga_max)

    My settings (on a test/dev/lab-box):
    System@oracle11 SQL > see the memory settings

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    hi_shared_memory_address integer 0
    whole big memory_max_target 3G
    whole large memory_target 3G
    shared_memory_address integer 0
    System@oracle11 SQL > show parameter sga

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    lock_sga boolean FALSE
    PRE_PAGE_SGA boolean FALSE
    SGA_MAX_SIZE large integer 0
    SGA_TARGET large integer 0
    System@oracle11 SQL > show parameter pga

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    pga_aggregate_target large integer 0

    This way I pushed things like Oracle by itself, memory allocation to everywhere where oracle needs him the most.

    Brgds
    Johan

  • Count (*) with the nested query

    Hello
    I have a question about the count (*) with the nested query.

    I have a table T1 with these columns:
    Number of C1
    Number of C2
    Number of C3
    Number of C4
    Number of C5

    (The type of each column is not relevant for example).

    This query:
    Select C1, C2, C3, C4
    from T1
    Group C1, C2

    It is not correct becausa C3 and C4 are the columns specified in the GROUP BY expression.

    If you run this query:
    Select count (*)
    (select C1, C2, C3, C4
    from T1
    Group C1, C2)

    I don't have an error message (properly, the result is the number of records).

    Why?

    Thank you.

    Best regards
    Luca

    because the optimizer rewrites as

    SELECT     COUNT(*)
                  FROM   T1
              GROUP BY   C1, C2  
    

    G.

    Edited by: g. March 1, 2011 09:19

Maybe you are looking for