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.

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 gives in sorted order without order by ,in 11g it is not.

    we are facing a strange problem.
    we have M Views on which we perform select operation ,we put joins of M Views and get the results by select operation , the results was in sorted order (asc) and we were not using any order by clause in the select query , this was in oracle 10G.
    The compelte schema where these M views are and also the underneath tables are now migrated to oracle 11g using import/export option.
    Now the queries which was giving the result set in sorted order (asc), are not given the result set in sorted order anymore. it is in different order but I think at always return the same order not asc or desc but an specific random order .
    we can not change the query as of now as there are 1000+ and each query would require a order by statement .
    Do we have any parameters which can be change , so that we can force oracle to use a different plan so that it gives result in order ?
    the select queries are very simple ones not complicated no extra function or group by is used in most of the queries.
    Please suggest possible solutions . Thanks much.

    Su**** wrote:
    Please guide me how to go to this doc link ,i am newbi, and do not how to go to this link.
    MOS Doc 345048.1 ('Group By' Does Not Guarantee a Sort Without Order By Clause In 10g and Above)
    Go to http://support.oracle.com, log in to My Oracle Support, and search for 345048.1 If you don't have a My Oracle Support account, you'll need to contact whoever manages your company's Oracle support and ask them to create an account for you.
    Basically, no version of Oracle has ever guaranteed the order of results if you don't specify an ORDER BY clause. In 10g, the only algorithm that was available to implement a GROUP BY happened to sort the results as a side effect. 11g introduced a new algorithm for grouping results that is more efficient and does not have the side effect of ordering the results. Most likely, your query plans have changed to use the more efficient grouping algorithm.
    If you want the results to be sorted, you should add an appropriate ORDER BY clause. If you go through the MOS document, there will also be suggestions for ways that you can disable the new grouping algorithm though I would not recommend that.
    Justin

  • 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]

  • How to verify stored procedures in Oracle 10g.

    I would like to locate default stored procedure in Oracle 10g database.
    And Suggest which stored procedure can be converted in to JAVA code ??

    If the Java part of the question refers to looking for potential to speed up your stored procedures:
    You should consider native compilation which transfers your code to shared libraries which are bound to the DB kernel.
    In this case however consider, that this does not make any sense/improvement for pure data access statements but only for procedures consisting of complex algorithmic processing.
    For details refer to
    [How native compilation works|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2280]
    and
    [Setting Up and Testing PL/SQL Native Compilation|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2309]

  • 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."

  • Kindly suggest oracle automation testing tools supporting oracle 10g forms

    Hi,
    We would like to automate oracle 10g forms in our company. kindly suggest oracle automation tools supporting oracle 10g forms other than OATS.
    If only OATS tool is available in Oracle, please suggest user guide for OATS.
    Regards,
    Sairam

    Hi Sairam,
    You can find OATS docs in OATS installation package itself. You can find separate pdf files for each OATS product(OpenScript Programmer Preference, OFT, OLT, OTM, Administrator etc).
    Regards,
    Deepu M

  • 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.

  • 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.

  • Looking for suggestion for SOAP over HTTP API to Oracle 10G

    I need to be able to write data to an oracle 10g database through a SOAP over HTTP connection. What is the suggest packages to do such an action.
    Best regards,
    Dale

    I suspect the problem is that the actual communication between client & Oracle DB server is done on a random "high port"; not 1522.
    The packets on the high port are not getting through the VPN.
    What I have made work in the past is to use ssh tunneling.
    Good Luck, you might need it.

  • UK Oracle User Group (UKOUG) fires back at suggestion that customers have 'hostile' relationship with Oracle

    In a 24 November article in Computing, the United Kingdom’s leading business technology publication, the UK Oracle User Group (UKOUG) differed with the suggestion from the Campaign for Clear Licensing that customers have a hostile relationship with Oracle.

    In a 24 November article in Computing, the United Kingdom’s leading business technology publication, the UK Oracle User Group (UKOUG) differed with the suggestion from the Campaign for Clear Licensing that customers have a hostile relationship with Oracle.

  • PL/SQL Sort an array Oracle 10g

    Does Oracle 10g have a built in method to sort an array (collection)?

    A quick method for sorting ( no massive data ) may be the following.
    SQL> set serveroutput on
    SQL> declare
      2     tab sys.owa_util.vc_arr;
      3     type sorted_tab is table of varchar2(32767) index by varchar2(32767);
      4     sorted sorted_tab;
      5     id1 pls_integer;
      6     id2 varchar2(32767);
      7  begin
      8     tab(1) := 'hello';
      9     tab(2) := 'george';
    10     tab(5) := 'no';
    11     id1 := tab.FIRST;
    12     WHILE id1 IS NOT NULL LOOP
    13             sorted(tab(id1)) := tab(id1);
    14             id1 := tab.NEXT(id1);
    15     END LOOP;
    16
    17
    18
    19     id2  := sorted.FIRST;
    20     WHILE id2 IS NOT NULL LOOP
    21             dbms_output.put_line(sorted(id2));
    22             id2 := sorted.NEXT(id2);
    23     END LOOP;
    24  end;
    25  /
    george
    hello
    no
    PL/SQL procedure successfully completed.But next time be correct. Index by tables defined in packages are not considered as collections.
    Bye Alessandro
    Edited by: Alessandro Rossi on 4-nov-2008 16.51

  • Need Advise and Suggestions-Oracle 10g

    Hi,
    I have been working on databases as DB developer(mainly PLsql)--Oracle 10g
    Recently,i have joined in a particular position where I have been asked to find out areas where
    improvement is necessary / or areas where improvement or changes would help very much and also gradually implement all best practises avaialable.
    So,could you please help me with these queries
    (1)What are the most important areas that i can start with the database which would impact largely the entire database.How can i start with it? any steps or process
    (2)I had once taken a report out for the expensive SQLs running.But that dint help much...because those SQLs were used temporarily on and off.
    Similarly,what are the other points to be looked on.
    (3)Things which can be replaced with the industry standarad better ones fully.
    an example would be...like.."following a particular naming format,or coding style,etc
    Thanks
    Rohit

    Hi Rohit,
    This is a pretty huge subject. To start, I'd say you need to talk to the business. Talk to the users of the database, cause they are your customers. Get a clear understanding of the most critical business processes. Start with the most critical ones, and get performance profiles. How long do they take to run? What's the customer's perception of the process performance? If it's acceptable, move on to the next one. If it's not acceptable, you'll need to dig deeper. Look at each piece of the process. Where is the most time being spent? Can it be improved? This step will be a combination of process improvement and setting the correct expectation. Often, the user doesn't really know what is realistic in terms of performance. If you have a 2 billion row table that needs to get full table scanned, expecting a response time of a few seconds just simply isn't going to happen. You need to clearly convey that to the customer. On the other hand, at the same time, you should be on the lookout for real improvements. If you can re-write the SQL or add an index, and eliminate the FTS on that 2 billion row table, maybe a response time of a few seconds is actually realistic.
    It's all about understanding the system, and understanding the customer's needs, and how they intersect. It will be an iterative process, and will take some time.
    As to "best practices", I'm not a fan of them. Understand your system, understand your customer's needs, and understand how Oracle actually works. If you can master that, you'll be unstoppable. Note that many, many people, much smarter people than me, have spent a lifetime trying to master those three points... :-)
    Good luck with your new job!
    -Mark

  • Oracle 10g configuration Kindly give your suggestions

    Hi Gurus,
    I am an oracle developer. Planning to switch myself as ORACLE DBA. it is very intersting to study the oracle internal. i need to have some practical analysis.
    Kindly help me for below queries
    1) Planning to install Oracle enterprise edition. kindly tell me the configuration details for installing oracle 10g or oracle 9i in the laptop. I need the RAM configuration and DISK memory configuration requirment details.
    2) Laptop is better or desktop?
    Kindly give me your advise and tips that will be veryhelpfull for me as ORACLE dba.
    kINDLY REPLY
    s

    oraclehema wrote:
    Hi Gurus,
    I am an oracle developer. Planning to switch myself as ORACLE DBA. it is very intersting to study the oracle internal. i need to have some practical analysis.
    Kindly help me for below queries
    1) Planning to install Oracle enterprise edition. kindly tell me the configuration details for installing oracle 10g or oracle 9i in the laptop. Why start your learning on a de-supported version? Start with 11.2.0.1
    I need the RAM configuration and DISK memory configuration requirment details.All the requirements are listed in the fine Installation Guide
    >
    2) Laptop is better or desktop?
    Oracle doesn't care
    Kindly give me your advise and tips that will be veryhelpfull for me as ORACLE dba.
    As others have said, the best recommendation is to download either VMplayer (free from VMware) or VMworkstation (about US$185 from VMware, but with better management tools than the free version) or VirtualBox (free from Oracle, but not quite as easy to work with as VMware). With any of these tools you can create a virtual machine on your laptop/desktop. On that virtual machine you can install Oracle Linux (free from Oracle). Once you have that built, you can download and install any Oracle product you want -- includeing Database Enterprise Edition -- free from Oracle for self-study purposes.
    kINDLY REPLY
    sPS:
    Learning how to look things up in the documentation is time well spent investing in your career. To that end, you should drop everything else you are doing and do the following:
    Go to tahiti.oracle.com.
    Drill down to your product and version.
    <b><i><u>BOOKMARK THAT LOCATION</u></i></b>
    Spend a few minutes just getting familiar with what is available here. Take special note of the "books" and "search" tabs. Under the "books" tab you will find the complete documentation library.
    Spend a few minutes just getting familiar with what <b><i><u>kind</u></i></b> of documentation is available there by simply browsing the titles under the "Books" tab.
    Open the Reference Manual and spend a few minutes looking through the table of contents to get familiar with what <b><i><u>kind</u></i></b> of information is available there.
    Do the same with the SQL Reference Manual.
    Do the same with the Utilities manual.
    You don't have to read the above in depth. They are <b><i><u>reference</b></i></u> manuals. Just get familiar with <b><i><u>what</b></i></u> is there to <b><i><u>be</b></i></u> referenced. Ninety percent of the questions asked on this forum can be answered in less than 5 minutes by simply searching one of the above manuals.
    Then set yourself a plan to dig deeper.
    - Read a chapter a day from the Concepts Manual.
    - Take a look in your alert log. One of the first things listed at startup is the initialization parms with non-default values. Read up on each one of them (listed in your alert log) in the Reference Manual.
    - Take a look at your listener.ora, tnsnames.ora, and sqlnet.ora files. Go to the Network Administrators manual and read up on everything you see in those files.
    - When you have finished reading the Concepts Manual, do it again.
    Give a man a fish and he eats for a day. Teach a man to fish and he eats for a lifetime.
    PPS:
    Why are you considering making this change? There will always be more jobs for developers than for DBAs. What is your motivation? Please don't tell me it's because of the money.
    Edited by: EdStevens on Aug 1, 2012 7:04 AM

Maybe you are looking for