Oracle 10g group by clause

I have one SQL query using a GROUP BY clause and no ORDER BY clause is used. When executed in Oracle 8i, the query results are returned ordered by first column mentioned in the GROUP BY clause. When the same query is executed in Oracle 10g, the query results are returned withour ordering the data by the first column in the GROUP BY clause. It works only when I explicitly mention the ORDER BY clause. Can you please explain this? In Orcale 8i, is it that, by default, the data is ordered by the first column mentioned in the GROUP BY clause when ORDER BY clause is not mentioned?
In which order does oracle 10g sorts when I use group by clause in oracle 10g

[email protected] wrote:
the use of group by is to group based on some column value, in this case why does the the output differs in rows. why does the output, when you use group by is not the following formatSorry, but this is a totally fruitless topic. Why are you bothering with something that is totally internal to the DBMS? If you want the data ordered, use ORDER BY, it's that simple.
Check out this link, if you want some discussion on it:
[http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:74320098178823]

Similar Messages

  • Oracle 10g group by sorting

    Hello friends
    Pls refere to my previous thread where we have discussed on sorting oprtion of Adding order by whereever group by is applicable
    ORACLE 10G group by sorting Suggestion rqd
    Read?
    Then come to my point
    if there is multiple columns for the group by then if we want to include order by clause, same number of columns has to be included in the order by also.
    i dont think it is so
    example'
    SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
    from part_sen
    group by partno, part_desc
    order by partno, part_desc
    qty1 qty2 partno partdesc
    70     101     I001     BRAKE SHOE
    56     54     I002     HORN
    30     30     I003     GEAR
    15     5     I004     DOOR
    5     5     I007     MOTOR GEAR
    10     15     I008     ANCILLARY
    10     15     I009     Window
    so in order by clause we can include only the first column.. that is partno
    SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
    from part_sen
    group by partno, part_desc
    order by partno
    Same result i get.
    Pls give your suggestion
    s

    ALex,
    SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
    from part_sen
    group by partno, part_desc
    70     101     I001     BRAKE SHOE
    56     54     I002     HORN
    30     30     I003     GEAR
    15     5     I004     DOOR
    5     5     I007     MOTOR GEAR
    10     15     I008     ZLLADER
    10     15     I008     OCTLADER
    10     15     I008     ANCILLARY
    10     15     I008     BALLLADER
    10     15     I009     Window
    SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
    from part_sen
    group by partno, part_desc
    order by partno
    70     101     I001     BRAKE SHOE
    56     54     I002     HORN
    30     30     I003     GEAR
    15     5     I004     DOOR
    5     5     I007     MOTOR GEAR
    10     15     I008     ANCILLARY
    10     15     I008     BALLLADER
    10     15     I008     OCTLADER
    10     15     I008     ZLLADER
    without ordering the second column part_desc it is properly ordered how?
    so adding order by partno is same as order by partno,part_desc
    Pls reply
    S

  • ORACLE 10G group by sorting Suggestion rqd

    Hai friends,
    recently we migrated from Oracle 9i to oracle 10g. We are instructed that Group by will not sort the records in Oracle 10g, so we are asked to add Order By Clause in wherever applicable in the package.
    But after migration i inserted 100 records in 10g database and tested. I am getting correct sorting of records based on Group by column. Can any one explain me why it is? I heard the news sorting will difer on Oracle 10g versions. I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0. if it automaticallly sorts, then no need to change the package for sortiing right?
    Give me your valuable suggestions..
    S

    And here's a simple example on 10.2.0.4 that clearly shows the results are not sorted.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    SQL> select object_type, count(*) from all_objects group by object_type;
    OBJECT_TYPE                     COUNT(*)
    CONSUMER GROUP                         2
    INDEX PARTITION                      718
    TABLE SUBPARTITION                    14
    SEQUENCE                             228
    SCHEDULE                               1
    TABLE PARTITION                      301
    PROCEDURE                             21
    ...Like everyone else has already said, Oracle does not guarantee the order from a group by clause with no order by.
    If you need the results in order you must use an order by clause.
    Pretty simple really.

  • Oracle 10g cd's

    please i want oracle 10g cd's
    if you can tell me send me to
    [email protected]

    Got these informations in OCP Oracle database 10g new features for administrators study guide :
    "In addition to the new installation features, the Oracle 10g installer includes many performance and management enhancements over 9i. Oracle 10g groups the products into separate CDs so that you need to use only one CD at a time. The following are some of the CDs that ship with
    Oracle 10g; all these are included in one DVD:
    Oracle Database 10g
    Oracle Database 10g Companion CD
    Oracle Database 10g Client
    Oracle Cluster Ready Services
    Oracle Database Documentation Library
    The installation completes in about 20 minutes and requires only one CD. The EM Webstage and Apache, which were installed with Oracle 9i, are no longer installed with the Oracle 10g database.
    Oracle 10g has a simplified software install and database creation; the disk requirement for software is now less."

  • Oracle 9i and Oracle 10g CD's

    Oracle 9i is 3 CD's.
    Oracle 10g is only one CD.
    Why is this difference?

    Got these informations in OCP Oracle database 10g new features for administrators study guide :
    "In addition to the new installation features, the Oracle 10g installer includes many performance and management enhancements over 9i. Oracle 10g groups the products into separate CDs so that you need to use only one CD at a time. The following are some of the CDs that ship with
    Oracle 10g; all these are included in one DVD:
    Oracle Database 10g
    Oracle Database 10g Companion CD
    Oracle Database 10g Client
    Oracle Cluster Ready Services
    Oracle Database Documentation Library
    The installation completes in about 20 minutes and requires only one CD. The EM Webstage and Apache, which were installed with Oracle 9i, are no longer installed with the Oracle 10g database.
    Oracle 10g has a simplified software install and database creation; the disk requirement for software is now less."

  • Group By clause in oracle 10g help needed

    Hi
    we have a requirement that get the AR aging details at customer level.I have written the following query to fetch the correct rows at invoice level.But now i need to sum the amounts and i should show at invoice level and customer level.Could you please help me how can i group by customer level.
    Here is the query i used
    select ps.org_id
    , sob.SET_OF_BOOKS_ID
    , sob.CHART_OF_ACCOUNTS_ID
    , gcc.SEGMENT1 Company
    , gcc.SEGMENT2 Location
    , gcc.SEGMENT3 Department
    , gcc.SEGMENT4 Account
    , gcc.SEGMENT5 Future_1
    , gcc.SEGMENT6 Future_2
    , gcc.SEGMENT7 Future_3
    , gcc.CONCATENATED_SEGMENTS gl_cc_concat_kff
    , ps.trx_number
    , ps.trx_date
    , ps.due_date
    , ps.invoice_currency_code
    , sob.currency_code SOB_Currency_Code
    , ps.class
    , ps.amount_due_original
    , ps.amount_due_original * nvl(ps.exchange_rate, 1) acctd_amount_due_original
    , ps.amount_due_remaining
    , ps.acctd_amount_due_remaining
    , ps.status
    , ps.cust_trx_type_id
    , ps.customer_site_use_id
    , ps.customer_trx_id
    , ps.cash_receipt_id
    , ps.gl_date
    , rctlda.CODE_COMBINATION_ID
    , ps.customer_id
    , nvl(rcta.ATTRIBUTE5,ps.CUSTOMER_ID) End_Customer_Id
    , rc.customer_number
    , rc2.CUSTOMER_NUMBER Brand_Cust_no
    , round((sysdate-ps.due_date))
    from gl_sets_of_books sob
    , hr_operating_units ou
    , ar_payment_schedules_all ps
    , ra_customers rc
    , ra_cust_trx_line_gl_dist_all rctlda
    , gl_code_combinations_kfv gcc
    , ra_customer_trx_all rcta
    , ra_customers rc2
    where sob.set_of_books_id = ou.set_of_books_id
    and ou.organization_id = ps.org_id
    and ps.status = 'OP'
    and ps.org_id is not null
    and ps.CUSTOMER_ID=rc.CUSTOMER_ID
    and ps.CUSTOMER_TRX_ID=rctlda.CUSTOMER_TRX_ID
    and rctlda.ACCOUNT_CLASS='REC'
    and rctlda.latest_rec_flag = 'Y'
    and rctlda.CODE_COMBINATION_ID=gcc.CODE_COMBINATION_ID
    and ps.CUSTOMER_TRX_ID=rcta.CUSTOMER_TRX_ID
    and gcc.CODE_COMBINATION_ID=39446
    -and ps.trx_number = '1-15O0A8O'
    --and    rc.CUSTOMER_NUMBER='1-10PA5KX'
    and nvl(rcta.ATTRIBUTE5,ps.CUSTOMER_ID)=rc2.CUSTOMER_ID
    Could any one help me how to get the same columns with sum( ps.amount_due_original ) for each customer.I tried to use group by clause but it is again giving invoice level.
    But my req is for each customer invoice amount should be summed and it should give the total
    Thanks
    Y

    if you need to have the sum of invoice related to each customer then may also need to check for the
    CUBE
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9448
    and example here
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2066443
    and ROLLUP
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9445
    I couldn't follow with all your SQL statement, or I could rewrite it for you again
    Thanks
    Edited by: user9532576 on Jul 21, 2009 9:24 AM

  • Not a GROUP BY expression - Oracle 10g bug?

    Hi,
    I am geting 00979. 00000 - "not a GROUP BY expression" error on Oracle 10g 10.2.0.4.0 - 64bit Production.
    To illustrate my problem I created following example.
    Let think I have some shop with clothes. Everytime I sell something, I store this information in the database - storing actual time, clothes type (trousers, socks, ...) and the size of the piece (M, L, XL, ...).
    Now, system counts statistics every hour. So it goes thrue the table with sold pieces and counts the number of pieces per clothes type and per size from the beginning of the day. It is important to realize that it is from the beginning of the day. Because of that, the number of sold pieces in the statistical table grows every hour (or is at least on the same value as in previous hour).
    Now, from this statistical table I need to make new statistic. I want a statistic how many pieces per size I sold every hour.
    I created this query for that:
    SELECT TIME, xSIZE, (SOLD  - NVL((SELECT SUM(S1.SOLD)
                                      FROM STATISTICS S1
                                      WHERE S1.xSIZE = S.xSIZE
                                        AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
                                        AND TO_CHAR(S1.TIME, 'HH24') != '23'
                                        AND S1.xSIZE IS NOT NULL
                                      GROUP BY TRUNC(S1.TIME, 'HH24'), S1.xSIZE),0)) SOLD
    FROM(
    SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
    FROM STATISTICS S
    WHERE S.xSIZE IS NOT NULL
    GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
    --ORDER BY 1 DESC
    ) S
    ORDER BY TIME DESC, xSIZE ASCFirst I select number of sold pieces per hour per size. To get number of sold pieces for particular hour, I need to substract from this value number of sold pieces from previous hour. I decided to do this with parameter query...
    Running the query like this I get "not a GROUP BY expression" error. However if I uncomment the "ORDER BY 1 DESC" statement, the query works. I am pretty sure it has to do something with this line:
    AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
    If you modify this query like this:
    SELECT TIME, xSIZE, (SOLD  - NVL((SELECT SUM(S1.SOLD)
                                      FROM STATISTICS S1
                                      WHERE S1.xSIZE = S.xSIZE
                                        --AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
                                        AND TO_CHAR(S1.TIME, 'HH24') != '23'
                                        AND S1.xSIZE IS NOT NULL
                                      GROUP BY  S1.xSIZE),0)) SOLD
    FROM(
    SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
    FROM STATISTICS S
    WHERE S.xSIZE IS NOT NULL
    GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
    --ORDER BY 1 DESC
    ) S
    ORDER BY TIME DESC, xSIZE ASCRemoved joining the tables on truncated time and grouping by the truncated time -> The query does not fail...
    And now the best...if you run the first query on Oracle 11g (Release 11.1.0.6.0 - 64bit Production), it works.
    Does anybody know why is the first query not working on 10g? Is there some bug or limitation for this server version?
    Please don't say me to rewrite the query in another way, I already did it, so it works on 10g as well. I am just curious why it doesn't work on 10g.
    Finally here are some data for testing.
    CREATE TABLE STATISTICS(
      TIME DATE DEFAULT SYSDATE,
      TYPE VARCHAR2(20),
      xSIZE VARCHAR2(2),
      SOLD NUMBER(5,0) DEFAULT 0
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'M', 10);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'M', 3);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'L', 1);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'L', 50);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Trousers', 'XL', 7);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'XL', 3);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'T-Shirt', 'M', 13);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'L', 60);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Trousers', 'XL', 15);
    INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'XL', 6);Edited by: user12047225 on 20.9.2011 23:12
    Edited by: user12047225 on 20.9.2011 23:45

    It is a known issue when optimizer decides to expand in-line view. You can add something (besides ORDER BY you already used) to in-line view to prevent optimizer from expanding it. For example:
    SQL> SELECT  TIME,
      2          xSIZE,
      3          (SOLD - NVL(
      4                      (
      5                       SELECT  SUM(S1.SOLD)
      6                         FROM  STATISTICS S1
      7                         WHERE S1.xSIZE = S.xSIZE
      8                           AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
      9                           AND TO_CHAR(S1.TIME, 'HH24') != '23'
    10                           AND S1.xSIZE IS NOT NULL
    11                           GROUP BY TRUNC(S1.TIME, 'HH24'),
    12                                    S1.xSIZE
    13                      ),
    14                      0
    15                     )
    16          ) SOLD
    17    FROM  (
    18           SELECT  TRUNC(S.TIME, 'HH24') TIME,
    19                   S.xSIZE,
    20                   SUM(S.SOLD) SOLD
    21             FROM  STATISTICS S
    22             WHERE S.xSIZE IS NOT NULL
    23             GROUP BY TRUNC(S.TIME, 'HH24'),
    24                      S.xSIZE
    25           --ORDER BY 1 DESC
    26          ) S
    27    ORDER BY TIME DESC,
    28             xSIZE ASC
    29  /
             SELECT  TRUNC(S.TIME, 'HH24') TIME,
    ERROR at line 18:
    ORA-00979: not a GROUP BY expression
    SQL> SELECT  TIME,
      2          xSIZE,
      3          (SOLD - NVL(
      4                      (
      5                       SELECT  SUM(S1.SOLD)
      6                         FROM  STATISTICS S1
      7                         WHERE S1.xSIZE = S.xSIZE
      8                           AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
      9                           AND TO_CHAR(S1.TIME, 'HH24') != '23'
    10                           AND S1.xSIZE IS NOT NULL
    11                           GROUP BY TRUNC(S1.TIME, 'HH24'),
    12                                    S1.xSIZE
    13                      ),
    14                      0
    15                     )
    16          ) SOLD
    17    FROM  (
    18           SELECT  TRUNC(S.TIME, 'HH24') TIME,
    19                   S.xSIZE,
    20                   SUM(S.SOLD) SOLD,
    21                   ROW_NUMBER() OVER(ORDER BY SUM(S.SOLD)) RN
    22             FROM  STATISTICS S
    23             WHERE S.xSIZE IS NOT NULL
    24             GROUP BY TRUNC(S.TIME, 'HH24'),
    25                      S.xSIZE
    26           --ORDER BY 1 DESC
    27          ) S
    28    ORDER BY TIME DESC,
    29             xSIZE ASC
    30  /
    TIME      XS       SOLD
    20-SEP-11 L           9
    20-SEP-11 M           0
    20-SEP-11 XL         11
    20-SEP-11 L          51
    20-SEP-11 M          13
    20-SEP-11 XL         10
    6 rows selected.
    SQL> Or use subquery factoring (WITH clause) + undocumented hint MATERIALIZE:
    SQL> WITH S AS (
      2             SELECT  /*+ MATERIALIZE */ TRUNC(S.TIME, 'HH24') TIME,
      3                     S.xSIZE,
      4                     SUM(S.SOLD) SOLD
      5               FROM  STATISTICS S
      6               WHERE S.xSIZE IS NOT NULL
      7               GROUP BY TRUNC(S.TIME, 'HH24'),
      8                        S.xSIZE
      9             --ORDER BY 1 DESC
    10            )
    11  SELECT  TIME,
    12          xSIZE,
    13          (SOLD - NVL(
    14                      (
    15                       SELECT  SUM(S1.SOLD)
    16                         FROM  STATISTICS S1
    17                         WHERE S1.xSIZE = S.xSIZE
    18                           AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
    19                           AND TO_CHAR(S1.TIME, 'HH24') != '23'
    20                           AND S1.xSIZE IS NOT NULL
    21                           GROUP BY TRUNC(S1.TIME, 'HH24'),
    22                                    S1.xSIZE
    23                      ),
    24                      0
    25                     )
    26          ) SOLD
    27    FROM  S
    28    ORDER BY TIME DESC,
    29             xSIZE ASC
    30  /
    TIME      XS       SOLD
    20-SEP-11 L           9
    20-SEP-11 M           0
    20-SEP-11 XL         11
    20-SEP-11 L          51
    20-SEP-11 M          13
    20-SEP-11 XL         10
    6 rows selected.
    SQL> SY.

  • Default Sorting behaviour of Oracle 9i in 11g along with group by clause

    Hi,
    We have recently migrated from 9i to 11g. The reports from application comes in a jumbled fashion. Later we understood when there is a group by clause in the query, the recordset will be sorted by default in 9i and this feature is not available in 11g. Do anyone faced the same issue and resolved at the DB level.
    Only alternate we found is the change in code with addittional order by clause which will take a long time to complete and roll out the same.
    If anyone has got any immediate solution, please let me know.
    Thx in advance.
    Sheen

    Hi,
    A group by can sort (depending on the method of grouping) but it isn't necessary. If you want to sort the output you need the ORDER BY clause. There are different group by mechanismes between 9i and 11g. 10g introduced HASH GROUP BY where in 9i only the SORT GROUP BY existed. The latter gives a sorted set, the first not.
    if you want the same behaviour you can use "_gby_hash_aggregation_enabled parameter" = false, which disables the hash group by.
    Have also a look at the support document "'Group By' Does Not Guarantee a Sort Without Order By Clause In 10g and Above [ID 345048.1]".
    Herald ten Dam
    http://htendam.wordpress.com

  • GROUP BY clause diff in Sybase and Oracle

    Hi,
    I am migrating code from Sybase to Oracle and came across a strange issue which is widely known to others :)
    In Sybase , one can use columns or calculations in the SELECT expressions that don't appear
    in the GROUP BY clause of the query. Like
    SELECT order.custid,customer.name,MAX(payments)
    -> FROM order, customer
    -> WHERE order.custid = customer.custid
    -> GROUP BY order.custid;
    works fine but for SQL we need to add customer.name to GROUP BY clause.
    On the similar lines, here is my SQL query
    INSERT INTO GTT_CTRT_recalc_proc
    (id_fin_rec,
    id_imnt,
    id_instr_opn,
    dt_instr_opn,
    dt_opn,
    dt_cls_loanet,
    dt_prcss,
    am_invst)
    SELECT t1.id_fin_rec,
    t1.id_imnt,
    t1.id_instr_opn,
    t1.dt_instr_opn,
    t1.dt_opn,
    NVL(t1.dt_cls_loanet, l_dt_to),
    t1.dt_prcss,
    SUM(t2.am_invst) + (0.123 * (1 - abs(sign(0 - SUM(t2.am_invst)))))
    FROM GTT_CTRT_TEMP_recalc_process t1, GTT_CTRT_TEMP_recalc_process t2
    WHERE t2.id <= t1.id
    AND t2.id_imnt = t1.id_imnt
    AND t2.id_instr_opn = t1.id_instr_opn
    AND t2.dt_instr_opn = t1.dt_instr_opn
    GROUP BY t1.id_imnt,
    t1.id_instr_opn,
    t1.dt_instr_opn,
    t1.dt_opn,
    t1.dt_cls_loanet,
    t1.dt_prcss;
    Which does not have t1.id_fin_rec in GROUP BY failing it in SQL.
    I know that if I add this column in GROUP BY it will work fine but I am told to keep the functionality as it is as the result before and after adding the column would be diff of-course.
    Please guide me about what can be done in this situation and is there any work around for this?
    Thanks,
    Aashish

    That's a piece of nasty denormalisation. We shoudl also expect trouble we do stuff like that. Anyway, I think encapsulating the stuff from T2 into an inline view should sort you out....
    INSERT INTO GTT_CTRT_recalc_proc
    (id_fin_rec,
    id_imnt,
    id_instr_opn,
    dt_instr_opn,
    dt_opn,
    dt_cls_loanet,
    dt_prcss,
    am_invst)
    SELECT t1.id_fin_rec,
    t1.id_imnt,
    t1.id_instr_opn,
    t1.dt_instr_opn,
    t1.dt_opn,
    NVL(t1.dt_cls_loanet, l_dt_to),
    t1.dt_prcss,
    , t2.total
    FROM GTT_CTRT_TEMP_recalc_process t1
        , ( select id_imnt,
                    id_instr_opn,
                    dt_instr_opn,
                    SUM(am_invst) + (0.123 * (1 - abs(sign(0 - SUM(am_invst))))) AS total
            FROM GTT_CTRT_TEMP_recalc_process
           GROUP BY  id_imnt,
                           id_instr_opn,
                           dt_instr_opn ) t2
    WHERE t2.id <= t1.id
    AND t2.id_imnt = t1.id_imnt
    AND t2.id_instr_opn = t1.id_instr_opn
    AND t2.dt_instr_opn = t1.dt_instr_opn
    GROUP BY t1.id_imnt,
    t1.id_instr_opn,
    t1.dt_instr_opn,
    t1.dt_opn,
    t1.dt_cls_loanet,
    t1.dt_prcss;Cheers, APC
    blog: http://radiofreetooting.blogspot.com
    Edited by: APC on Mar 16, 2009 2:31 PM
    Forgot to include GROUP BY in the inline view

  • Oracle 10g Reports: Control Break using Group By Rollup

    Oracle 10g Contol-Break Reporting
    Hello. I am trying to create a report using Group By Rollup. The report should look like:
    MONTH......._WEEK_..... CODE.... TOTAL
    JULY..........WEEK 1..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ................WEEK 2..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ...............WEEK 3..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ...............WEEK 4..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ..........................MTH Tot:.....16
    AUG..........WEEK 1..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ................WEEK 2..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ...............WEEK 3..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ...............WEEK 4..... K1...........2
    ............................. K1...........2
    .............................SUB:.........4
    ..........................MTH Tot:.....16
    ..........................GRND TOT: 32
    Not sure how to group the codes into the correct month/week and the labels are a problem. Here is the table/data and a my poor attempt at using the Group by rollup. I'm still working on it but any help would be very nice.
    create table translog
    ttcd          VARCHAR2(5) not null,
    stime TIMESTAMP(6) not null,
    etime TIMESTAMP(6)
    insert into translog ( TTCD, STIME, ETIME)
    values ('T4', '01-JUL-12 12.00.01.131172 AM', '01-JUL-12 12.00.16.553256 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T4', '01-JUL-12 12.00.17.023083 AM', '01-JUL-12 12.00.37.762118 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('K2', '01-JUL-12 12.00.38.262408 AM', '01-JUL-12 12.00.40.686331 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('U1', '01-JUL-12 12.00.40.769385 AM', '01-JUL-12 12.00.41.281300 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('SK4', '08-JUL-12 12.00.41.746175 AM', '08-JUL-12 12.00.51.775487 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '08-JUL-12 12.00.53.274039 AM', '08-JUL-12 12.00.53.802800 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1','08-JUL-12 12.00.54.340423 AM', '08-JUL-12 12.01.03.767422 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '08-JUL-12 12.01.04.699631 AM', '08-JUL-12 12.01.04.744194 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('S2', '15-JUL-12 12.01.04.796472 AM', '15-JUL-12 12.01.04.817773 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '15-JUL-12 12.01.04.865641 AM', '15-JUL-12 12.01.05.154274 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '15-JUL-12 12.01.05.200749 AM', '15-JUL-12 12.01.05.508953 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '15-JUL-12 12.01.06.876433 AM', '15-JUL-12 12.01.07.510032 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '15-JUL-12 12.01.07.653582 AM', '15-JUL-12 12.01.07.686764 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('S2', '15-JUL-12 12.01.07.736894 AM', '15-JUL-12 12.01.08.163321 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-JUL-12 12.01.08.297696 AM', '22-JUL-12 12.01.08.562933 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '22-JUL-12 12.01.08.583805 AM', '22-JUL-12 12.01.08.620702 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-JUL-12 12.01.08.744821 AM', '22-JUL-12 12.01.08.987524 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-JUL-12 12.01.09.096695 AM', '22-JUL-12 12.01.09.382138 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-JUL-12 12.01.09.530122 AM', '22-JUL-12 12.01.10.420257 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '01-AUG-12 12.01.10.550234 AM', '01-AUG-12 12.01.10.581535 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('S2', '01-AUG-12 12.01.10.628756 AM', '01-AUG-12 12.01.10.656373 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '01-AUG-12 12.01.10.740711 AM', '01-AUG-12 12.01.10.768745 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '01-AUG-12 12.01.10.819635 AM', '01-AUG-12 12.01.10.900849 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '01-AUG-12 12.01.09.530122 AM', '01-AUG-12 12.01.10.420257 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '08-AUG-12 12.01.11.231004 AM', '08-AUG-12 12.01.24.073071 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '08-AUG-12 12.01.24.202920 AM', '08-AUG-12 12.01.24.244538 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('S2', '08-AUG-12 12.01.24.292334 AM', '08-AUG-12 12.01.24.318852 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '08-AUG-12 12.01.24.362643 AM', '08-AUG-12 12.01.24.397662 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1','15-AUG-12 12.01.09.530122 AM', '15-AUG-12 12.01.10.420257 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1', '15-AUG-12 12.01.24.414572 AM', '15-AUG-12 12.01.24.444615 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L2W', '15-AUG-12 12.01.24.478739 AM', '15-AUG-12 12.01.25.020265 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('K4', '15-AUG-12 12.01.25.206721 AM', '15-AUG-12 12.01.25.729493 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '15-AUG-12 12.01.25.784746 AM', '15-AUG-12 12.01.39.226921 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1','15-AUG-12 12.01.39.517953 AM', '15-AUG-12 12.01.50.775295 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-AUG-12 12.01.57.676446 AM', '22-AUG-12 12.01.58.252945 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-AUG-12 12.01.09.530122 AM', '22-AUG-12 12.01.10.420257 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-AUG-12 12.01.58.573242 AM', '22-AUG-12 12.02.10.651922 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('L1', '22-AUG-12 12.02.11.209305 AM', '22-AUG-12 12.02.24.140456 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('SK4','22-AUG-12 12.02.25.204035 AM', '22-AUG-12 12.02.25.580603 AM');
    insert into translog ( TTCD, STIME, ETIME)
    values ('T1','22-AUG-12 12.02.25.656474 AM', '22-AUG-12 12.02.25.689249 AM');
    select
    decode(grouping(trunc(stime)),1, 'Grand Total: ', trunc(stime)) AS "DATE"
    ,decode(grouping(ttcd),1, 'SUB TTL:', ttcd) CODE,count(*) TOTAL
    from translog
    group by rollup (trunc(stime),ttcd);}
    Thank you.

    830894 wrote:
    Oracle 10g Contol-Break Reporting
    Hello. I am trying to create a report using Group By Rollup. The report should look like:Couple of things:
    1) Your test data setup dows not match with your expected output &
    2) layout of data (like control break) should ideally be carried out using reporting tools
    Here is what you are probably looking for:
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> create table translog
      2  (
      3  ttcd VARCHAR2(5) not null,
      4  stime TIMESTAMP(6) not null,
      5  etime TIMESTAMP(6)
      6  );
    Table created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T4', '01-JUL-12 12.00.01.131172 AM', '01-JUL-12 12.00.16.553256 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T4', '01-JUL-12 12.00.17.023083 AM', '01-JUL-12 12.00.37.762118 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('K2', '01-JUL-12 12.00.38.262408 AM', '01-JUL-12 12.00.40.686331 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('U1', '01-JUL-12 12.00.40.769385 AM', '01-JUL-12 12.00.41.281300 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('SK4', '08-JUL-12 12.00.41.746175 AM', '08-JUL-12 12.00.51.775487 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '08-JUL-12 12.00.53.274039 AM', '08-JUL-12 12.00.53.802800 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1','08-JUL-12 12.00.54.340423 AM', '08-JUL-12 12.01.03.767422 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '08-JUL-12 12.01.04.699631 AM', '08-JUL-12 12.01.04.744194 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('S2', '15-JUL-12 12.01.04.796472 AM', '15-JUL-12 12.01.04.817773 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '15-JUL-12 12.01.04.865641 AM', '15-JUL-12 12.01.05.154274 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '15-JUL-12 12.01.05.200749 AM', '15-JUL-12 12.01.05.508953 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '15-JUL-12 12.01.06.876433 AM', '15-JUL-12 12.01.07.510032 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '15-JUL-12 12.01.07.653582 AM', '15-JUL-12 12.01.07.686764 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('S2', '15-JUL-12 12.01.07.736894 AM', '15-JUL-12 12.01.08.163321 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-JUL-12 12.01.08.297696 AM', '22-JUL-12 12.01.08.562933 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '22-JUL-12 12.01.08.583805 AM', '22-JUL-12 12.01.08.620702 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-JUL-12 12.01.08.744821 AM', '22-JUL-12 12.01.08.987524 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-JUL-12 12.01.09.096695 AM', '22-JUL-12 12.01.09.382138 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-JUL-12 12.01.09.530122 AM', '22-JUL-12 12.01.10.420257 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '01-AUG-12 12.01.10.550234 AM', '01-AUG-12 12.01.10.581535 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('S2', '01-AUG-12 12.01.10.628756 AM', '01-AUG-12 12.01.10.656373 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '01-AUG-12 12.01.10.740711 AM', '01-AUG-12 12.01.10.768745 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '01-AUG-12 12.01.10.819635 AM', '01-AUG-12 12.01.10.900849 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '01-AUG-12 12.01.09.530122 AM', '01-AUG-12 12.01.10.420257 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '08-AUG-12 12.01.11.231004 AM', '08-AUG-12 12.01.24.073071 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '08-AUG-12 12.01.24.202920 AM', '08-AUG-12 12.01.24.244538 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('S2', '08-AUG-12 12.01.24.292334 AM', '08-AUG-12 12.01.24.318852 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '08-AUG-12 12.01.24.362643 AM', '08-AUG-12 12.01.24.397662 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1','15-AUG-12 12.01.09.530122 AM', '15-AUG-12 12.01.10.420257 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1', '15-AUG-12 12.01.24.414572 AM', '15-AUG-12 12.01.24.444615 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L2W', '15-AUG-12 12.01.24.478739 AM', '15-AUG-12 12.01.25.020265 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('K4', '15-AUG-12 12.01.25.206721 AM', '15-AUG-12 12.01.25.729493 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '15-AUG-12 12.01.25.784746 AM', '15-AUG-12 12.01.39.226921 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1','15-AUG-12 12.01.39.517953 AM', '15-AUG-12 12.01.50.775295 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-AUG-12 12.01.57.676446 AM', '22-AUG-12 12.01.58.252945 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-AUG-12 12.01.09.530122 AM', '22-AUG-12 12.01.10.420257 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-AUG-12 12.01.58.573242 AM', '22-AUG-12 12.02.10.651922 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('L1', '22-AUG-12 12.02.11.209305 AM', '22-AUG-12 12.02.24.140456 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('SK4','22-AUG-12 12.02.25.204035 AM', '22-AUG-12 12.02.25.580603 AM');
    1 row created.
    SQL> insert into translog ( TTCD, STIME, ETIME)
      2  values ('T1','22-AUG-12 12.02.25.656474 AM', '22-AUG-12 12.02.25.689249 AM');
    1 row created.
    SQL> commit ;
    Commit complete.
    SQL> select case when row_number() over (partition by mth order by mth, wk, ttcd) = 1 then mth end as "Month"
      2        ,case when row_number() over (partition by mth, wk order by mth, wk, ttcd) = 1 and wk is not null then 'WEEK '||wk end as "Week"
      3        ,case when gttcd = 1 and gwk = 0 and gmth = 0 then 'SUB:'
      4              when gttcd = 1 and gwk = 1 and gmth = 0 then 'Month Total:'
      5              when gttcd = 1 and gwk = 1 and gmth = 1 then 'Grand Total:'
      6              else ttcd
      7         end as "Code"
      8        ,cnt as "Total"
      9    from (
    10          select trunc(stime, 'MM') as mth, to_char(stime, 'W') as wk, ttcd, count(*) as cnt
    11                ,grouping(trunc(stime, 'MM')) as gmth, grouping(to_char(stime, 'W')) as gwk, grouping(ttcd) as gttcd
    12            from translog
    13           group by rollup(trunc(stime, 'MM'), to_char(stime, 'W'), ttcd)
    14           order by trunc(stime, 'MM'), to_char(stime, 'W'), ttcd
    15         ) ;
    Month     Week   Code              Total
    01-JUL-12 WEEK 1 K2                    1
                     T4                    2
                     U1                    1
                     SUB:                  4
              WEEK 2 L1                    2
                     SK4                   1
                     T1                    1
                     SUB:                  4
              WEEK 3 L1                    1
                     S2                    2
                     T1                    3
                     SUB:                  6
              WEEK 4 L1                    4
                     T1                    1
                     SUB:                  5
                     Month Total:         19
    01-AUG-12 WEEK 1 L1                    1
                     S2                    1
                     T1                    3
                     SUB:                  5
              WEEK 2 L1                    1
                     S2                    1
                     T1                    2
                     SUB:                  4
              WEEK 3 K4                    1
                     L1                    3
                     L2W                   1
                     T1                    1
                     SUB:                  6
              WEEK 4 L1                    4
                     SK4                   1
                     T1                    1
                     SUB:                  6
                     Month Total:         21
                     Grand Total:         40
    35 rows selected.

  • Returning 250 rows with 1000 Values in "IN" Clause Oracle 10g On IBM AIX !!

    Hi,
    Recently we have done the OS migration of Oracle 10g Server from Windows Server to IBM AIX. Everything is fine, But today we came across one crucial bug in the code, i.e In the Select Query, though we're expecting 1000 rows with 1000 values in "IN" Clause , It's returning Only 250 rows. Where as it's returning 1000 rows in Windows Environment with 1000 values in "IN" Clause. I have browsed throgh Google for the resolution but failed to get that.
    This is something like,
    In Oracle 10g On windows :-
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 1000 rows.
    In Oracle 10g On IBM AIX ,
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 250 rows. Pls help me, what could be the reason for this. and what needs to be checked to fix this.
    Pls suggest !!!
    Raja

    mmmh. Did you compared the select count(*) from your_table; in the two cases.
    If the result is not good and nobody has deleted rows between migration and your test, you migration need to be replayed.
    Which migration did you select, Transportable database or exp/imp...?
    Edited by: Dba Z on 16 août 2009 08:56

  • How to handle Group by clause Dynamically in Oracle Form

    Hi Expert,
    Here i have problem :
    i want display record with passing group by clause Parameter
    Example :
    Select zone,district,postal,count(Do_no) ,sum(Sales_Amt)
    from DLV_ORD_mast
    group by :zone,:district,:Postal
    1-o/p like :
    if user pass the :zone parameter in group by clause then record display like below o/p
    zone count sls_amt
    South 2 1000
    central 3 5000
    East 4 600
    2-o/p
    if use pass the :District parameter in group by clause then record display like below O/P
    zone count sls_amt
    South/Dist1 2 1000
    central /Dist2 3 5000
    central /Dist3 1 500
    East /Dist4 4 600
    2-o/p
    if use pass the :postal parameter in group by clause then record display like below O/P
    zone count sls_amt
    South/Dist1/postal1 2 1000
    central /Dist2/Postal2 3 5000
    central /Dist3/postal3 1 500
    East /Dist4/postal4 4 600
    so if anybody come across same senario then Please give me the solution for this problem .
    pleassssssssssssssssssssssssss
    Thanks
    Abhishek

    Build a block one a Query FROM clause, like
    SELECT GROUPCOL,
           CNT,
           SUMM
      FROM (Select zone GROUPCOL,
                   count(Do_no) CNT,
                   sum(Sales_Amt) SUMM
              from DLV_ORD_mast
             group by zone
    )Then at runtime, change the the block QUERY_DATASOURCE_NAME by SET_BLOCK_PROPERTY depending on the parameter, e.g. to
    SELECT GROUPCOL,
           CNT,
           SUMM
      FROM (Select zone ||', '|| DISTRICT GROUPCOL,
                   count(Do_no) CNT,
                   sum(Sales_Amt) SUMM
              from DLV_ORD_mast
             group by zone ||', '|| DISTRICT
    )

  • Oracle 10G New Feature........Part 1

    Dear all,
    from last couple of days i was very busy with my oracle 10g box,so i think this is right time to
    share some intresting feature on 10g and some internal stuff with all of you.
    Have a look :-
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Oracle 10g Memory and Storage Feature.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1.Automatic Memory Management.
    2.Online Segment Shrink
    3.Redolog Advisor, checkpointing
    4.Multiple Temporary tablespace.
    5.Automatic Workload Repository
    6.Active Session History
    7.Misc
    a)Rename Tablespace
    b)Bigfile tablespace
    c)flushing buffer cache
    8.ORACLE INTERNAL
    a)undocumented parameter (_log_blocks_during_backup)
    b)X$ view (x$messages view)
    c)Internal Structure of Controlfile
    1.Automatic memory management
    ================================
    This feature reduce the overhead of oracle DBA.previously mostly time we need to set diff oracle SGA parameter for
    better performance with the help of own experience,advice views and by monitoring the behaviour
    of oracle database.
    this was just time consuming activity.........
    Now this feature makes easy life for oracle DBA.
    Just set SGA_TARGET parameter and it automatically allocate memory to different SGA parameter.
    it focus on DB_CACHE_SIZE
    SHARED_POOL_SIZE
    LARGE_POOL
    JAVA_POOL
    and automatically set it as
    __db_cache_size
    __shared_pool_size
    __large_pool_size
    __java_pool_size
    check it in alert_log
    MMAN(memory manager) process is new in 10g and this is responsible for sga tuning task.
    it automatically increase and decrease the SGA parameters value as per the requirement.
    Benefit:- Maximum utlization of available SGA memory.
    2.Online Segment Shrink.
    ==========================
    hmmmmm again a new feature by oracle to reduce the downtime.Now oracle mainly focus on availablity
    thats why its always try to reduce the downtime by intrducing new feature.
    in previous version ,reducing High water mark of table was possible by
    Exp/imp
    or
    alter table move....cmd. but on these method tables was not available for normal use for long hrs if it has more data.
    but in 10g with just few command we can reduce the HWmark of table.
    this feature is available for ASSM tablespaces.
    1.alter table emp enable row movement.
    2.alter table emp shrink space.
    the second cmd have two phases
    first phase is to compact the segment and in this phase DML operations are allowed.
    second phase(shrink phase)oracle shrink the HWM of table, DML operation will be blocked at that time for short duration.
    So if want to shrink the HWM of table then we should use it with two diff command
    first compact the segment and then shrink it on non-peak hrs.
    alter table emp shrink space compact. (This cmd doesn't block the DML operation.)
    and alter table emp shrink space. (This cmd should be on non-peak hrs.)
    Benefit:- better full table scan.
    3.Redolog Advisor and checkpointing
    ================================================================
    now oracle will suggest the size of redo log file by V$INSTANCE_RECOVERY
    SELECT OPTIMAL_LOGFILE_SIZE
    FROM V$INSTANCE_RECOVERY
    this value is influence with the value of FAST_START_MTTR_TARGET .
    Checkpointing
    Automatic checkpointing will be enable after setting FAST_START_MTTR_TARGET to non-zero value.
    4.Multiple Temporary tablespace.
    ==================================
    Now we can manage multiple temp tablespace under one group.
    we can create a tablespace group implicitly when we include the TABLESPACE GROUP clause in the CREATE TEMPORARY TABLESPACE or ALTER TABLESPACE statement and the specified tablespace group does not currently exist.
    For example, if group1 is not exists,then the following statements create this groups with new tablespace
    CREATE TEMPORARY TABLESPACE temp1 TEMPFILE '/u02/oracle/data/temp01.dbf'
    SIZE 50M
    TABLESPACE GROUP group1;
    --Add Existing temp tablespace into group by
    alter tablespace temp2 tablespace group group1.
    --we can also assign the temp tablespace group on database level as default temp tablespace.
    ALTER DATABASE <db name> DEFAULT TEMPORARY TABLESPACE group1;
    benefit:- Better I/O
    One sql can use more then one temp tablespace
    5.AWR(Automatic Workload Repository):-
    ================================== AWR is built in Repository and Central point of Oracle 10g.Oracle self managing activities
    is fully dependent on AWR.by default after 1 hr, oracle capure all database uses information and store in AWR with the help of
    MMON process.we called it Memory monitor process.and all these information are kept upto 7 days(default) and after that it automatically purge.
    we can generate a AWR report by
    SQL> @?/rdbms/admin/awrrpt
    Just like statspack report but its a advance and diff version of statspack,it provide more information of Database as well as OS.
    it show report in Html and Text format.
    we can also take manually snapshot for AWR by
    BEGIN
    DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
    END;
    **The STATISTICS_LEVEL initialization parameter must be set to the TYPICAL or ALL to enable the Automatic Workload Repository.
    [oracle@RMSORA1 oracle]$ sqlplus / as sysdba
    SQL*Plus: Release 10.1.0.2.0 - Production on Fri Mar 17 10:37:22 2006
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> @?/rdbms/admin/awrrpt
    Current Instance
    ~~~~~~~~~~~~~~~~
    DB Id DB Name Inst Num Instance
    4174002554 RMSORA 1 rmsora
    Specify the Report Type
    ~~~~~~~~~~~~~~~~~~~~~~~
    Would you like an HTML report, or a plain text report?
    Enter 'html' for an HTML report, or 'text' for plain text
    Defaults to 'html'
    Enter value for report_type: text
    Type Specified: text
    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    DB Id Inst Num DB Name Instance Host
    * 4174002554 1 RMSORA rmsora RMSORA1
    Using 4174002554 for database Id
    Using 1 for instance number
    Specify the number of days of snapshots to choose from
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Entering the number of days (n) will result in the most recent
    (n) days of snapshots being listed. Pressing <return> without
    specifying a number lists all completed snapshots.
    Listing the last 3 days of Completed Snapshots
    Snap
    Instance DB Name Snap Id Snap Started Level
    rmsora RMSORA 16186 16 Mar 2006 17:33 1
    16187 16 Mar 2006 18:00 1
    16206 17 Mar 2006 03:30 1
    16207 17 Mar 2006 04:00 1
    16208 17 Mar 2006 04:30 1
    16209 17 Mar 2006 05:00 1
    16210 17 Mar 2006 05:31 1
    16211 17 Mar 2006 06:00 1
    16212 17 Mar 2006 06:30 1
    16213 17 Mar 2006 07:00 1
    16214 17 Mar 2006 07:30 1
    16215 17 Mar 2006 08:01 1
    16216 17 Mar 2006 08:30 1
    16217 17 Mar 2006 09:00 1
    Specify the Begin and End Snapshot Ids
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Enter value for begin_snap: 16216
    Begin Snapshot Id specified: 16216
    Enter value for end_snap: 16217
    End Snapshot Id specified: 16217
    Specify the Report Name
    ~~~~~~~~~~~~~~~~~~~~~~~
    The default report file name is awrrpt_1_16216_16217.txt. To use this name,
    press <return> to continue, otherwise enter an alternative.
    Benefit:- Now DBA have more free time to play games.....................:-)
    Advance version of statspack
    more DB and OS information with self managing capabilty
    New Automatic alert and database advisor with the help of AWR.
    6.Active Session History:-
    ==========================
    V$active_session_history is view that contain the recent session history.
    the memory for ASH is comes from SGA and it can't more then 5% of Shared pool.
    So we can get latest and active session report from v$active_session_history view and also get histortical data of
    of session from DBA_HIST_ACTIVE_SESS_HISTORY.
    v$active_session_history include some imp column like:-
    ~SQL identifier of SQL statement
    ~Object number, file number, and block number
    ~Wait event identifier and parameters
    ~Session identifier and session serial number
    ~Module and action name
    ~Client identifier of the session
    7.Misc:-
    ========
    Rename Tablespace:-
    =================
    in 10g,we can even rename a tablespace by
    alter tablespace <tb_name> rename to <tb_name_new>;
    This command will update the controlfile,data dictionary and datafile header,but dbf filename will be same.
    **we can't rename system and sysaux tablespace.
    Bigfile tablespace:-
    ====================
    Bigfile tablespace contain only one datafile.
    A bigfile tablespace with 8K blocks can contain a 32 terabyte datafile.
    Bigfile tablespaces are supported only for locally managed tablespaces with automatic segment-space management.
    we can take the advantage of bigfile tablespace when we are using ASM or other logical volume with RAID.
    without ASM or RAID ,it gives poor response.
    syntax:-
    CREATE BIGFILE TABLESPACE bigtbs
    Flushing Buffer Cache:-
    ======================
    This option is same as flushing the shared pool,but only available with 10g.
    but i don't know, whats the use of this command in prod database......
    anyway we can check and try it on test server for tuning n testing some query etc....
    SQL> alter system flush buffer_cache;
    System altered.
    ++++++++++++++++++
    8.Oracle Internal
    ++++++++++++++++++
    Here is some stuff that is not related with 10g but have some intresting things.
    a)undocumented parameter "_log_blocks_during_backup"
    ++++++++++++++++++++++++
    as we know that oracle has generate more redo logs during hotbackup mode because
    oracle has to maintain the a complete copy of block into redolog due to split block.
    we can also change this behaviour by setting this parameter to False.
    If Oracle block size equals the operating system block size.thus reducing the amount of redo generated
    during a hot backup.
    WITHOUT ORACLE SUPPORT DON'T SET IT ON PROD DATABASE.THIS DOCUMENT IS JUST FOR INFORMATIONAL PURPOSE.
    b)some X$ views (X$messages)
    ++++++++++++++++
    if you are intresting in oracle internal architecture then x$ view is right place for getting some intresting things.
    X$messages :-it show all the actions that a background process do.
    select * from x$messages;
    like:-
    lock memory at startup MMAN
    Memory Management MMAN
    Handle sga_target resize MMAN
    Reset advisory pool when advisory turned ON MMAN
    Complete deferred initialization of components MMAN
    lock memory timeout action MMAN
    tune undo retention MMNL
    MMNL Periodic MQL Selector MMNL
    ASH Sampler (KEWA) MMNL
    MMON SWRF Raw Metrics Capture MMNL
    reload failed KSPD callbacks MMON
    SGA memory tuning MMON
    background recovery area alert action MMON
    Flashback Marker MMON
    tablespace alert monitor MMON
    Open/close flashback thread RVWR
    RVWR IO's RVWR
    kfcl instance recovery SMON
    c)Internal Structure of Controlfile
    ++++++++++++++++++++++++++++++++++++
    The contents of the current controlfile can be dumped in text form.
    Dump Level Dump Contains
    1 only the file header
    2 just the file header, the database info record, and checkpoint progress records
    3 all record types, but just the earliest and latest records for circular reuse record types
    4 as above, but includes the 4 most recent records for circular reuse record types
    5+ as above, but the number of circular reuse records included doubles with each level
    the session must be connected AS SYSDBA
    alter session set events 'immediate trace name controlf level 5';
    This dump show lots of intresting information.
    it also show rman recordes if we used this controlfile in rman backup.
    Thanks
    Kuljeet Pal Singh

    You can find each doc in html and pdf format on the Documentation Library<br>
    You can too download all the documentation in html format to have all on your own computer here (445.8MB)<br>
    <br>
    Nicolas.

  • Creation of view with clob column in select and group by clause.

    Hi,
    We are trying to migrate a view from sql server2005 to oracle 10g. It has clob column which is used in group by clause. How can the same be achived in oracle 10g.
    Below is the sql statament used in creating view aling with its datatypes.
    CREATE OR REPLACE FORCE VIEW "TEST" ("CONTENT_ID", "TITLE", "KEYWORDS", "CONTENT", "ISPOPUP", "CREATED", "SEARCHSTARTDATE", "SEARCHENDDATE", "HITS", "TYPE", "CREATEDBY", "UPDATED", "ISDISPLAYED", "UPDATEDBY", "AVERAGERATING", "VOTES") AS
      SELECT content_ec.content_id,
              content_ec.title,
              content_ec.keywords,
              content_ec.content content ,
              content_ec.ispopup,
              content_ec.created,
              content_ec.searchstartdate,
              content_ec.searchenddate,
            COUNT(contenttracker_ec.contenttracker_id) hits,
              contenttypes_ec.type,
              users_ec_1.username createdby,
              Backup_Latest.created updated,
              Backup_Latest.isdisplayed,
              users_ec_1.username updatedby,
              guideratings.averagerating,
              guideratings.votes
         FROM users_ec users_ec_1
                JOIN Backup_Latest
                 ON users_ec_1.USER_ID = Backup_Latest.USER_ID
                RIGHT JOIN content_ec
                JOIN contenttypes_ec
                 ON content_ec.contenttype_id = contenttypes_ec.contenttype_id
                 ON Backup_Latest.content_id = content_ec.content_id
                LEFT JOIN guideratings
                 ON content_ec.content_id = guideratings.content_id
                LEFT JOIN contenttracker_ec
                 ON content_ec.content_id = contenttracker_ec.content_id
                LEFT JOIN users_ec users_ec_2
                 ON content_ec.user_id = users_ec_2.USER_ID
         GROUP BY content_ec.content_id,
         content_ec.title,
         content_ec.keywords,
         to_char(content_ec.content) ,
         content_ec.ispopup,
         content_ec.created,
         content_ec.searchstartdate,
         content_ec.searchenddate,
         contenttypes_ec.type,
         users_ec_1.username,
         Backup_Latest.created,
         Backup_Latest.isdisplayed,
         users_ec_1.username,
         guideratings.averagerating,
         guideratings.votes;
    Column Name      Data TYpe
    CONTENT_ID     NUMBER(10,0)
    TITLE          VARCHAR2(50)
    KEYWORDS     VARCHAR2(100)
    CONTENT          CLOB
    ISPOPUP          NUMBER(1,0)
    CREATED          TIMESTAMP(6)
    SEARCHSTARTDATE     TIMESTAMP(6)
    SEARCHENDDATE     TIMESTAMP(6)
    HITS          NUMBER
    TYPE          VARCHAR2(50)
    CREATEDBY     VARCHAR2(20)
    UPDATED          TIMESTAMP(6)
    ISDISPLAYED     NUMBER(1,0)
    UPDATEDBY     VARCHAR2(20)
    AVERAGERATING     NUMBER
    VOTES          NUMBERAny help realyy appreciated.
    Thanks in advance
    Edited by: user512743 on Dec 10, 2008 10:46 PM

    Hello,
    Specifically, this should be asked in the
    ASP.Net MVC forum on forums.asp.net.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Problem in oracle 10g release 2

    I faced strange problem while selecting data from join of tables (in oracle 10g). While selecting, when the order of fields in "group by" clause is changed, the resulting summary of values is changed too. For eg,
    query1 = SELECT F1, F2, F3, SUM(F4)
    FROM TBL1
    GROUP BY F1, F2, F3, F4
    query2 = SELECT F1, F2, F3, SUM(F4)
    FROM TBL1
    GROUP BY F2, F4, F1, F3
    The results SUM(F4) given by query1 and query 2 do not match. While testing these querries in differnt environments, we found such problem in ORACLE 10g RELEASE 2 only and not in ORACLE 10g RELEASE 1. I need to execute this query in oracle 10g. Can anybody help me finding the exact problem?

    The results SUM(F4) given by query1 and query 2 do not matchSince the group by clause is not same, the result of sum can be different.
    Can you provide us some dataset ?
    Nicolas.

Maybe you are looking for

  • Need help with publishing as animated .gif

    I'm having trouble publishing my project as an animated .gif.  My project, which consists of two different animated movie clips, plays just fine when test it (Shift + Enter).  But, when I go to publish it, the animations don't show up.  The settings

  • Inline style - decimal value for dimension break designer

    Hi all. I'm using JDeveloper 11.1.2.1 & ADF. Just to let you know that decimal value in dimension css selectors (like width...) added using inline style break UI designer. af:tree table -> nodeStamp facet -> column -> inlineStyle -> width:305.0px bre

  • Error code -304155.

    Hi all,  Here's my problem: Error -304155 occurred at niLvFpga_Open_PXIe-7975R.vi Possible reason(s): FlexRIO: Downloading to the FPGA is not supported on this OS. Please use the RIO Device Setup utility to download your bitfile to the flash, and the

  • Printing Wish List

    Is there a way to print all the cd's and songs saved in my wish list? I'd like to review them so I can figure out which ones to order first. Also, once I buy a song or cd from my wish list, it doesn't look like the song is removed from the list. How

  • Print Jobs disappearing

    When printing to a shared USB printer on a windows XP box the prints are going but nothing happens. The printer is an HP P1006 which supports PCL5e which I have loaded via Gimp-print. I shared the printer on the XP box and I can install it easily on