Order by group left report

Hi,
I have a sql which contains an order by clause (order by field1, field2), the query runs fine in SQL*Plus.
I tried to create a Group Left report in Reports 10g. When I run the report, it disregards the order by clause.
The report works fine if I picked tabular.
Thanks in advance
Tushar

Let us take an example of a table with the following structure -
create table test (grade varchar2(3),
detail varchar2(10));
Here GRADE is the column which contains numbers as well as alphabets or
alpha-numerals.
A normal query on the table would result in the following -
select grade, detail from test
GRADE DETAIL
1 DET1
1 DET2
1 DET3
1 DET4
2 DET1
2 DET2
2 DET3
5 DET1
A DET1
A DET2
B DET1
B DET2
B DET3
B DET4
10 DET1
10 DET2
10 DET3
If you want the GRADE to be sorted in a numeric order first and then alphabetically,
you can use the concept explained .
select grade, detail
from test
order by decode( TO_CHAR(NVL(LENGTH(TRANSLATE(grade,'A1234567890','A')),0)),
'0',LPAD(grade,8),
grade)
GRADE DETAIL
1 DET1
1 DET2
1 DET3
1 DET4
2 DET1
2 DET2
2 DET3
5 DET1
10 DET1
10 DET3
10 DET2
A DET1
A DET2
B DET1
B DET2
B DET3
B DET4
If you were to write the above query in Oracle Reports (tabular style),
the output would be the same as above.
But if you create a group left or group above style with GRADE as the
higher group, the same query would give the following result -
GRADE DETAIL
1 DET1
DET2
DET3
DET4
10 DET1
DET3
DET2
2 DET1
DET2
DET3
5 DET1
A DET1
DET2
B DET1
DET2
DET3
DET4
This is because although the server sends back the resulting set in the desired
ordered fashion, the grouping on grade does a further sort (ascending - the
default). But this sort is done alphabetically since this is a varchar2 column.
To avoid this or to achieve the desired output (numbers to appear sorted first
and then alphabets), use the decode in the select list itself.
Now the query for the report becomes -
select decode( TO_CHAR(NVL(LENGTH(TRANSLATE(grade,'A1234567890','A')),0)),
'0',LPAD(grade,8),
grade) grade
, detail
from test
The order by clause in the query is irrelevant since the grouping inside reports
anyway does the sort. The result would look like
GRADE DETAIL
1 DET1
DET2
DET3
DET4
2 DET1
DET2
DET3
5 DET1
10 DET1
DET3
DET2
A DET1
DET2
B DET1
DET2
DET3
DET4

Similar Messages

  • Group Left report: problem in order the columns

    Hi,
    I have a Group Left report in report6i with group A and Group B. Group A has columns AAA, BBB, CCC, DDD, EEE, FFF and Group B has coulmn YYY, ZZZ.
    The problem is report does not take order by clause. It sort the report by first column of Group A, does not reflect my order by clause.
    I created laxical variable in order to change order by clause dynamically.
    Any suggestion?
    Thanks in advance
    Dip

    Hi,
    I have a Group Left report in report6i with group A and Group B. Group A has columns AAA, BBB, CCC, DDD, EEE, FFF and Group B has coulmn YYY, ZZZ.
    The problem is report does not take order by clause. It sort the report by first column of Group A, does not reflect my order by clause.
    I created laxical variable in order to change order by clause dynamically.
    Any suggestion?
    Thanks in advance
    Dip

  • How to build a Matrix with Group Left Report

    I want to build a Matrix with Group Left Report,not Matrix with Group Above Report,i am still finding the solution, any help is useful.
    thanks
    <[email protected]>

    Hi,
    The problem in your output is not clear. The report output should appear like:
    Order Mode.....Sales_Rep_ID > 10..11..12..
    Online.........Order Status
    ...............A..............x....x...x
    ...............B..............x....x...x
    ...............C..............x....x...x
    Order Mode.....Sales_Rep_ID > 10..11..12..
    Retail.........Order Status
    ...............A..............x....x...x
    ...............B..............x....x...x
    ...............C..............x....x...x
    Here "Order Mode" is the group field (it repeats for every group). Could you pl specify what output you are getting?
    If the problem is that you don't want the Title (like "Order Mode" in the above example) to print in every group, just place it outside the group repeating frame. It will print only once.
    Navneet.

  • Help with Group Left Report

    Hi everyone,
    I created a Group left report with 4 grouping columns.Everthing is working fine but i am getting some problem with the order of the 3rd column(varchar).It is doing ascending order(As the Break order Propoerty of that column is ascending).
    But i am trying to do is the 3 rd column needs to be displayed by a specific (order by clause)
    But in group left report it is not considering the (order by clause of the query).It is doing sort by the grouping columns.Is there any way that i can sort a grouping column(other than asc and dsc).It needs to be displayed in the order of another column.
    Thanks
    phani

    Create another column (either in the query, or in the data model as formula) that would indicated the rank according to the desired sort order. You don't need to place the column into the layout, but use it to set the break order in the data model.

  • How to design Group Left Report using RTF method ( XML Publisher )

    Hi,
    I need to design Group Left Report using basic RTF method. I am able to design basic simple report and Group Above Report but I am not getting Group Left Report. Can anyone help me out.
    Thx N Regs,
    Khan.

    Group Left report can be done using table consisting of 1 row and 2 columns. Group header goes to the column 1, group details go to the second column. Group details can be also designed using table, in this case you get table within table cell. "for-each.." statement for the upper level group to be placed in the left column before the group header data. "end for-each.." to be placed in the second column after the detail data.

  • Need help in group left report

    i need help in group left report
    i am making group left report in which all group data on top is repeating as many time as detail record is .
    for axampel
    if
    group record:
    fielda fieldb field c
    fielda fieldb field c
    fielda fieldb field c
    fielda fieldb field c
    detail record :
    fieldd fielde feildf
    fieldd fielde feild
    fieldd fielde feild
    fieldd fielde feildf
    how i can show group record on top once and on each group record show detail record belong to master record.
    plz help me
    A.R

    I think you Should go for Group above report...
    and if you want group left only and also want to display master once then
    put all master fields above but yeah take care of it's master repeting frame
    it should not change...
    and if you want i can send you an example...
    Enjoy Oracle...

  • Group Left  report

    Helo all,
    Iam trying to create a group left report (Time report)
    I need something like this
    code Client_name county Average1
    02 Elias Mulain Central Cf_1/Count           North Cf_1/Count
    South Cf_1/Count
    SouthWest Cf_1/Count
    Cf_1= (staff_date-access_date)
    Count= Count(county)
    my query is
    select code,Client_name,county
    staff_date,access_date,hire_date
    from t1,t2,t
    as I selected code,Client_name,county in the group
    I selected one of the date columns and I made it invisible so that it doesn't display in the report. it prints lot of spaces for ex
    02 Elias Mulain Central
         North Cf_1/Count
    South Cf_1/Count
    SouthWest Cf_1/Count
    How do I get rid of this space.
    I tried creating 2 queries in datamodel one query for the group colums and other for the dates.
    But I am getting a "refrence col below frequncy...." error when I am trying to refer them for the calculations
    Please help me

    This was filed as a bug in Oracle Reports (May 15th 2003).

  • Group Left report does not sort DESCending

    Hello seniors...
    i have the following query that produces result as desired below at SQL level; i am aiming at rows to be displyed in the DESCending order..
    SQL> SELECT Z.ACATG_TYPE, Y.EXPN_CATG, z.ACATG_DESC, y.expn_code, y.expn_name,
      2  DECODE(Z.ACATG_TYPE,'I', x.closing) Income,
      3  DECODE(Z.ACATG_TYPE,'E', x.closing) Expense
      4  FROM(
      5  SELECT PSN_PARTY, expn_name, SUM(nvl(NETT,0)) nett,  SUM(nvl(DEBIT,0)) debit,  SUM(nvl(CREDIT,0
    )) credit,
      6  SUM((nvl(NETT,0)+nvl(DEBIT,0)-nvl(CREDIT,0))) CLOSING
      7  FROM (
      8  SELECT PSN_PARTY, 0 nett, SUM(nvl(debit,0)) DEBIT, SUM(nvl(CREDIT,0)) CREDIT
      9  FROM(
    10   SELECT PSN_TXN_DATE,PSN_PARTY, nvl(DEBIT,0) debit, nvl(CREDIT,0) credit
    11   FROM
    12       (
    94  where PSN_PARTY = expn_code
    95  GROUP BY PSN_PARTY, expn_name) x, expense_master y, Accounts_category z
    96  where x.psn_party = y.expn_code
    97  and   y.expn_catg = z.acatg_code
    98  and   z.acatg_type in ('I','E')
    99  ORDER BY Z.ACATG_TYPE DESC, Y.EXPN_CATG,y.expn_code;
    ACA EXPN_C ACATG_DESC                     EXPN_C EXPN_NAME                             INCOME       EXPENSE
    I   90     Income                         AC2000 Sale                                1333.000
    E   10     Expense                        AC0003 ELECTRICIRTY BILL                                   30.000
    E   10     Expense                        AC0005 TELEPHONE BILL                                      16.000
    E   10     Expense                        AC0007 TEA & SNACKS                                        17.000
    E   10     Expense                        AC0009 REPAIRS & MAINTENANCE                               15.000
    E   10     Expense                        AC0010 MOBILE BILL                                         45.000
    E   10     Expense                        AC0011 REFUND                                             220.000
    E   10     Expense                        AC0019 OFFICE EXPENCE                                      15.000
    E   40     Staff Salaries                 AC0006 STAFF SLALARY                                      250.000
    9 rows selected.But when i made use of the above query in my report with Group Left Option, i dont get it sorted in DESCending order.
    With Tabular type report it sorts correctly as above.
    The screen schot for better idea of my report is attached for the reference.
    [http://i995.photobucket.com/albums/af71/rhnshk/INCEXP.jpg|Report-Preview]
    [http://i995.photobucket.com/albums/af71/rhnshk/INCEXP1.jpg|ReportWizard-DataModel]
    [http://i995.photobucket.com/albums/af71/rhnshk/INCEXP2.jpg|ReportWizard-Groups]
    [http://i995.photobucket.com/albums/af71/rhnshk/INCEXP3.jpg|ReportWizard-Fields]
    [http://i995.photobucket.com/albums/af71/rhnshk/INCEXP4.jpg|ReportWizard-Totals]
    i want the rows with acatg_type = 'I' to be displayed first.
    Sorry for not attaching the complete SQL, but no issues if at all required, i can do that as well.
    Since its a long in-line view created SQL. thought the solution might come out showing this much part only.
    i am using Report 6i on 10g.
    Please help me.

    Thanks Arif,,
    Grouping/Break i need to be done with EXPN_CATG-within-ACATG_TYPE.
    if you can view the my report image links, u'll understand much better.
    EXPN_CODE is not part of the Group Fields.
    Still i tried re-arranging Group fields, but still the same..
    Row with ACATG_TYPE = 'I' is not moving up.
    Please suggest..

  • Group Left Order By

    Hi,
    I have a sql which contains an order by clause (order by field1, field2), the query runs fine in SQL*Plus.
    I tried to create a Group Left report in Reports 10g. (The report contains the Group on field1.) When I run the report, it disregards the order by clause. Is there some place else I need to look at?
    The report works fine if I I picked tabular, but then field1 repeats itself: i.e.
    Human Resources      John Smith
    Human Resources     Jane Doe
    If there is a way to suppress the repeating value, then I could use tabular format.
    Thanks in advance
    VC

    Figured it out.

  • Converting a Group Left to a Group Above Report

    I have created a dozen group left reports which I thought would only take up one page of data. I have found that some of them will actually require more pages but the report will only produce 1 page.
    As an example I created the same report but used the group above style and this time by default it creates multiple pages. So how can I change my other reports into the group above style - note I cannot use the wizard as I have made many layout changes which woujld be lost.

    It's not because of Group Left vs Group Above that report display only the first page. Make sure the Print Object On property of the repeation frames set to First Page Only, not All Pages.

  • Group by reports

    Hi
    I am using Oracle Reoprts 6i. I have a report where I need to
    group by using a single parent, multiple child relationship. For
    example, taking Employee number as the single parent and
    employee&#8217;s children&#8217;s names and the projects in which he has
    worked as the child records of employee number. I am not able to
    achieve this tree structure. i am trying to use a Group left
    report format. Can u pls help.
    Thanks in advance.
    Prabhu S

    hi all,
    my problem is solved now...heres what i was suggested by monica
    from oracle corp..tx monica.. i hope this mite be useful for
    others too.
    cheers,
    prabhu.
    Hello,
    Lets say you have three tables -
    Parent - ( A primary key)
    Child1 - ( B foreign key references Parent(A))
    Child2 - ( C foreign key references Parent(A))
    and B and C are not related.
    Create three queries in the data model -
    Q_1 - Parent which will create group G_Parent
    Q_2 - Child1 which will create group G_Child1
    Q_3 - Child2 which will create group G_Child2
    Create two data links -
    One from G_Parent(A) to G_child1(B)
    Other from G_Parent(A) to G_child2(C)
    In the layout -
    Select type as Group Left.
    Select the groups G_A,G_B,G_C to display down.
    Select the fields to display.
    Select template and run report.
    This will give you the desired result.
    Regards,
    Monica Samuel

  • Group Left Rpt - Dept Subtotal - S

    Have a Group Left Report - Have it set up with the Following
    Mgr Grp -
    Mgr
    Emp
    SumofXYZ
    Sumof123
    Sumofabc,
    Sumofdfe,
    Date Grp -
    Date,
    XYZ,
    123,
    ABC
    The report is set to Group on Mgr and Emp with Totals at Emp level, then a REPORT total generates at end of reprot ...The need I have is to be able to generate a Subtotal when the Mgr VALUE changes with the totals summing up all the EMP totals under that Mgr VALUE...have tried a few approaches ...any help would be greatly appreciated!!

    In the date model drag the column above all column on which you want to make a sub total on

  • Group by Left Report for Multiple Queries

    Afternoon folks,
    I have been pretty much writing my queries in Oracle Reports by having one long query (which includes multiple sub-queries) and then displaying the results (Mainly Counts and MEDIAN values).
    This has resulted in one very long query (difficult to manage and understand), not to mention slower performance. I would like to change that my making smaller queries and use data links to join the groups.
    Here is my Report request in hand. I need to build a Report that will be grouped by a Reporting Year and stratified by Age Groups and then Report various Counts of Students that are
    coming from various data sources (Tables). As of now, I have the Counts coming from at least 3 different data sources. So as you can imagine, my 3 sub queries have added to one
    very long query. Anymore requirements to the Report and it can lead to a big mess.
    Column '# of Students Enrolled' is coming from ENROLLMENT_TB table
    Columns '# of Students who took Math' and 'Marks > 60' are coming from COURSE_MATH table.
    Birth Date information is in the STUDENT_TB table (Since the Report needs to be stratified by Age Groups)
    Report Layout
    Reporting Year    Age Group         # of Students Enrolled   # of Students who took Math       Marks > 60   Median Score
    ========================================================================================================================
    2010              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                 
    2011              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                 
    2012              1960 - 1969                          999                           999              999            999                 
                      1970 - 1979                          999                           999              999            999                 
                      1980 - 1989                          999                           999              999            999                 
                      1990+                                999                           999              999            999                  Currently, I have 3 sub-queries
    Sub Query #1: # of Students Enrolled from ENROLLMENT_TB.
    Sub Query #2: # of the Enrolled Students who took Math from COURSE_MATH_TB
    Sub Query #3: # of the Enrolled Students who took Math from COURSE_MATH_TB and got Marks > 60. Median Score of this sampling.
    My thought would be to have them into Groups and then create a Report a s a Group Left to achieve the results. Any help or suggestions would be more than welcome.
    I have begun working on this Report but it is still taking quite long (Like 4 minutes) when the individual Queries (Q_COURSE_MATH and Q_COURSE_MATCH_60) are only taking 20 seconds each.
    My guess is the Grouping based on the age group is resulting in slower performance but I could be wrong.
    Also, the Query runs between pages and takes a long time to run. So, when I actually ran the Report, only the first page was formatted and then subsequent pages follow.
    Looking at the data model, is there something conceptually wrong?
    I have also not included the Query for Enrollment Counts to keep the Report simple.
    Data Links:
    Q_REPORTING_YEAR and Q_COURSE_MATH (Join condition: reporting_year and age_range_order_id)
    Q_REPORTING_YEAR and Q_COURSE_MATH_60 (Join condition: reporting_year and age_range_order_id)
    Data Layout:
    Q_REPORTING_YEAR
    select yrs.reporting_year,
           age_range.age_range_label,
           age_range.age_range_order_id
    from
      select to_char(Add_Months(To_Date ('01-JAN-2009', 'DD-MON-YYYY'), 12 * LEVEL), 'YYYY')   reporting_year
      from    DUAL
      CONNECT BY LEVEL < 4
    ) yrs,
      select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                 to_char(1900+ (rownum - 1)*10)                                                               age_start,
                 to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                 rownum                                                                                       age_range_order_id
      from    dual
      connect by rownum < 11
    ) age_range
    order by yrs.reporting_year, age_range.age_range_order_id
    Q_COURSE_MATH
    select reporting_year              cm_reporting_year,
           age_range_label             cm_age_range_label,
           age_range_order_id          cm_age_range_order_id,
           COUNT(distinct(student_id)) cm_student_count
    from
      select distinct cm.student_id                     student_id,
             to_char(cm.course_date, 'YYYY')           reporting_year,
             age_range.age_range_label        age_range_label,
             age_range.age_range_order_id   age_range_order_id
      from   course_math    cm,
             student_tb s,
               select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                          to_char(1900+ (rownum - 1)*10)                                                               age_start,
                          to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                          rownum                                                                                       age_range_order_id
               from    dual
               connect by rownum < 11
              ) age_range
        where  cm.student_id = s.student_id
        and exists ( select 'x' from sampling_student_vw w
                         where  w.student_id = cm.student_id )
        and     to_char(s.birth_date, 'YYYY') between age_range.age_start and age_range.age_stop
    ) q
    GROUP BY q.reporting_year, q.age_range_label, q.age_range_order_id
    Q_COURSE_MATH_60
    select reporting_year              cm_reporting_year,
           age_range_label             cm_age_range_label,
           age_range_order_id          cm_age_range_order_id,
           COUNT(distinct(student_id)) cm_student_count,
           MEDIAN(marks)                cm_median_60
    from
      select distinct cm.student_id                     student_id,
             to_char(cm.course_date, 'YYYY')           reporting_year,
             cm.marks                                  marks,
             age_range.age_range_label        age_range_label,
             age_range.age_range_order_id   age_range_order_id
      from   course_math    cm,
             student_tb s,
               select decode( rownum, 10, '1990+', to_char(1900+ (rownum-1)*10)||'-'|| to_char(1900+ (rownum)*10-1))   age_range_label,
                          to_char(1900+ (rownum - 1)*10)                                                               age_start,
                          to_char(decode(rownum, 10, to_char(sysdate, 'yyyy'), 1900+ (rownum)*10-1))                   age_stop,
                          rownum                                                                                       age_range_order_id
               from    dual
               connect by rownum < 11
              ) age_range
        where  cm.student_id = s.student_id
        and      cm.marks >= 60
        and exists ( select 'x' from sampling_student_vw w
                         where  w.student_id = cm.student_id )
        and     to_char(s.birth_date, 'YYYY') between age_range.age_start and age_range.age_stop
    ) q
    GROUP BY q.reporting_year, q.age_range_label, q.age_range_order_id

    Hi Arsalan,
    "Group by" is not a valid calculation option for calculated fields in the database object, nor is it for the calculation fields in your report.
    I believe that what you are trying to achieve is to have a SUM of all the sales done, grouped by Brand. This is typically something you configure while building your report(in Active Studio).
    If you for example would only want to show 2 out of 5 Brands in your report I suggest you use a filter(which is configured while building your report as well).
    For all calculation and operation options in calculated fields you can go to the Help section of BAM and search for "Calculation Operators and Expressions".
    I hope I helped you solve your problem.
    Kind regards,
    Martijn van der Kamp

  • GROUP BY & ORDER BY  in a Report

    How to Implement GROUP BY & ORDER BY in a Report?

    Hi,
    Order by: It is possible to sort the char value according to the values (asc or desc) of an atribute of this char...is this what you were looking for?
    Group by: May be can be achieved by drilldwon sequence, with the grouping char to the left of the char values to be grouped...again, is this what you had in mind?

  • Is this Oracle Reports bug – "break order property" in "group above" report

    Is this Oracle Reports bug – “break order property” in "group above" report
    Could anybody confirm that in "group above" report, we could only order the brake column's values with ""none" or "ascending" or "descending" provided by "break order property"?
    In the following example, “Dept” is brake column. Oracle Reports allows us to order values in “Dept” with “descending” provided by “break order property”:
    Dept 30
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 20
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 10
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    or “ascending” provided by “break order property”:
    Dept 10
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 20
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 30
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    I need to do:
    Dept 20
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 10
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Dept 30
    job ename salary
    xxx xxx xxx
    xxx xxx xxx
    Could I do this? Could anybody confirm that we could never ever do this, or If yes, how?
    Millions of thanks for advice.
    M.Z.
    Edited by: jielan on Sep 18, 2010 8:23 AM

    Why should that be a bug? You have a custom requirement and have to find a way to fulfill it. But, what is your actual sorting order? Do you have only this three departments? If so, you could add an addtional column in your query like
    DECODE(DEPT,  20, 1, 10, 2, 30, 3, 4) SORTINGput that column in the same group as dept and sort after that new column.

Maybe you are looking for

  • Get information about business object from view implementation class

    Hi, i´d like to develop some button behavior in a view. How can i get the information of the related business object like the order or the position. I like to disable buttons if specific status are set. Bye Richard

  • How do I embed pictures in e-mail?

    I need to imbed pictures into my e-mail instead of attaching them. My daughter is in the navy and can not get attachments. I have tried copy and paste but unless I do that from an e-mail sent to me it doesn't work. == This happened == Every time Fire

  • Screensaver does not start after upgrading to 10.7

    Since upgrading to 10.7 my screensaver does not start either by hot corner or automatically. I can get it to test from the preference pane, any suggestions?

  • What's the music in this Nokia Video ??

    Please Please Please help me!! I really want to know what's the music of this Nokia Video: http://europe.nokia.com/A41257168 Can anyone help?! I hope you will be able to find out the song! Thank you in advance guys! Message Edited by aeon19 on 08-Jan

  • Updated latest update for maverick and am having issues

    i updated this past weekend to the latest update for Mavericks. and cannot get past the system setting up screen. what can i do to get past this?