Group by multiple columns problem

I am having some problems with my query. For example:
SELECT STUDENTNUMBER FROM REGISTRATION
WHERE TERM='A1' AND YEAR=2008
GROUP BY STUDENTNUMBER
HAVING COUNT( COURSECODE) = 1;
which returns:
STUDENTNUMBER
123456
789012
6 rows selected
Which is ok, but the problem is i want to list out not only studentnumber but also the coursecode,year and the term of students. But if i do this:
SELECT STUDENTNUMBER,COURSECODE,YEAR,TERM,
FROM REGISTRATION WHERE TERM='A1'AND YEAR=2008
GROUP BY (STUDENTNUMBER,COURSECODE,YEAR,TERM)
HAVING COUNT( COURSECODE) = 1;
i got 50+ records in which most of them are duplicates!. To put it shortly i want the 6 records but with the coursecode,year,studentnumber and term listed. is there a workaround for this?

Thanks everyone for your suggestion!
I end up using Arun's query but modify it slightly to this:
SELECT STUDENTNUMBER,COURSECODE,YEAR,TERM
FROM REGISTRATION WHERE STUDENTNUM IN(
SELECT STUDENTNUMBER FROM REGISTRATION
WHERE TERM='A1' AND YEAR=2008
GROUP BY STUDENTNUMBER
HAVING COUNT(COURSECODE) = 1) AND TERM='A1' AND YEAR=2008;
Using the multiple set functions would also yields the same result.Anyway i would post the create table statements and insert statements for everyone's references.
CREATE TABLE REGISTRATION(
     CourseCode     VARCHAR(15)     NOT NULL     ,
     Year          NUMBER(4)     NOT NULL     ,
     Term          VARCHAR(5)     NOT NULL     ,
     StudentNumber     NUMBER(12)     NOT NULL     ,
     Lecturer          NUMBER(12)     NOT NULL     ,
     Grade          NUMBER(5,2)               ,
     CONSTRAINT REGISTRATION_PKEY PRIMARY KEY(CourseCode, Year, Term, StudentNumber, Lecturer),
     CONSTRAINT REGISTRATION_FKEY1 FOREIGN KEY(CourseCode) REFERENCES COURSE(CourseCode),
     CONSTRAINT REGISTRATION_FKEY2 FOREIGN KEY(StudentNum) REFERENCES STUDENT(StudentNumber),
     CONSTRAINT REGISTRATION_FKEY3 FOREIGN KEY(Lecturer) REFERENCES ACADSTAFF(StaffNum)
Insert statements:
INSERT INTO REGISTRATION VALUES('CSE235',2008,'A1',1292601,2001,null);
INSERT INTO REGISTRATION VALUES('CSE235',2008,'A2',8290012,2001,null);
INSERT INTO REGISTRATION VALUES('CSE235',2008,'A2',7246935,2002,null);
I want to list the student number, coursecode, year and term of students who registers for only one course in term "A1" in 2008.The result:
STUDENTNUM COURSECODE YEAR TERM
3000911 CSE101 2008 A1
3335010 CSE101 2008 A1
3011724 CSE101 2008 A1
8754117 CSE101 2008 A1
1032858 CSE101 2008 A1
3292880 CSE101 2008 A1
6 rows selected.
Edited by: user12231119 on Nov 16, 2009 9:19 PM

Similar Messages

  • Selectively Format Groups with Multiple Columns

    I have a bit of an obscure task I've been trying to hammer out to no avail.  I've searched quite a bit but can't seem to find anyone else who has attempted this.  I have two group by statements, one is a category and the other is a rank.  What I'm trying to do is organize the report so that there are category rows and below each category row is a set of columns for each rank with their associated values as such:
    category1
    rank1     rank2     rank3     rank4
    value1   value1    value1   value1
    value2   value2    value2   value2
    category2
    rank1     rank2     rank3
    value1   value1    value1
    value2   value2    value2
    I've tried using details>Section Expert>>Layout>Format Groups with multiple column.  Unfortunately, this applies to both groups putting the categories into columns instead of rows, making a mess.  Does anyone know of a way to selectively put groups into columns and ensure alignment?  In the above example the user would be able to compare rank values from multiple categories since they all line up.  Any help with this would be very much appreciated.

    Hi,
    Have you tried using a crosstab? Give this a shot:
    1) Group the report on Category
    2) Create a new group header section. Group Header b
    3) Place a crosstab in this section
    4) The columns would be the Rank field, I'm not sure about what you would like to show in the rows
    5) The summarized field would be the Value field ofcourse
    Let me know how this goes.
    -Abhilash

  • Groups into Multiple Columns

    Post Author: Donamese
    CA Forum: General
    I am trying to create a report that is split between 3 companies and all states using a distinct count of individuals (as there are duplicates in the data pool).  I would like the report to look like:
    State             Company 1                Company 2                 Company 3
    AL                       0                                 16                           5
    AR                      3                                  9                             4
    AZ                       5                                 0                              7
    Currently I can only get it to list vertical like:
    Company 1
    AL       0
    AR      3
    AZ       5
    Company 2
    AL     16
    etc....
    I am unable to get the formating of multiple columns with the grouping.  Is it possible?  And if

    Post Author: rookie10
    CA Forum: General
    Try inserting a Cross Tab in the Report or page header. Its pretty much like a pivot table.
    Use State as the Row, Company as the Column, Individuals as Summarized field using Distinct Count as the summary type.
    In customized style part of the cross tab you can hide some of the totals and such to get pretty close to the report above - supress subtotals and such.
    Hope this works for you. I was pretty excited when I found this feature in Crystal.
    Rookie10

  • Group By Multiple Columns

    I am using the BI plug-in to try and create a multi-column grouped report similar to below:
    Emp Name Emp ID Dept Job
    Bob_______100____Job1
    _________________Job2
    _________________Job3
    Tom______200____Job1
    I use the table form wizard, move all my nodes over and choose to group by Emp Name on my Rowset. I then click on Emp Name and choose to group by Emp Id. I then say ok to create output (choosing table). IS this how you are supposed to create multi-grouped report?

    Ok XML on the bottom.
    The STUDENT_ID and STUDENT NAME are the grouped fields.
    Layout would be a table looking like this:
    F STUDENT_ID STUDENT_NAME RELATION_DESC CONTACT_NAME ADDRESS_LINE1 PHONE EMERGENCY_PHONE
    Total Students Printed: ttt
    E
    Thanks for your help.
    you can email me template you create at: [email protected]
    <?xml version="1.0" encoding="UTF-8"?>
    <DATA>
    <ROWSET1>
    <ROWSET1_ROW>
    <STUDENT_NAME_LABEL>Student</STUDENT_NAME_LABEL>
    <STUDENT_ID_LABEL>ID#</STUDENT_ID_LABEL>
    </ROWSET1_ROW>
    </ROWSET1>
    <ROWSET2>
    <ROWSET2_ROW>
    <STUDENT_NAME>Adams, Angela Marie </STUDENT_NAME>
    <STUDENT_ID>CHS0001</STUDENT_ID>
    <CONTACT_RELATION>A</CONTACT_RELATION>
    <CONTACT_REL_DESC>Aunt</CONTACT_REL_DESC>
    <CONTACT_NAME>Ms. Margaret Mary Dale </CONTACT_NAME>
    <ADDRESS_LINE1>300 Main Street </ADDRESS_LINE1>
    <ADDRESS_LINE2>Freehold, NJ 07728</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 555-4354</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Adams, Angela Marie </STUDENT_NAME>
    <STUDENT_ID>CHS0001</STUDENT_ID>
    <CONTACT_RELATION>GF</CONTACT_RELATION>
    <CONTACT_REL_DESC>Grandfather</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr. George Adams </CONTACT_NAME>
    <ADDRESS_LINE1>132 Green Glade Drive </ADDRESS_LINE1>
    <ADDRESS_LINE2>Century City, NJ 09009</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 555-1890</PHONE>
    <PHONE_DESCRIPTION>Home</PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Adams, Angela Marie </STUDENT_NAME>
    <STUDENT_ID>CHS0001</STUDENT_ID>
    <CONTACT_RELATION>GM</CONTACT_RELATION>
    <CONTACT_REL_DESC>Grandmother</CONTACT_REL_DESC>
    <CONTACT_NAME>Mrs. Nancy Dale </CONTACT_NAME>
    <ADDRESS_LINE1>1402 Winding Way </ADDRESS_LINE1>
    <ADDRESS_LINE2>Century City, NJ 09009</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 555-9786</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Adams, Angela Marie </STUDENT_NAME>
    <STUDENT_ID>CHS0001</STUDENT_ID>
    <CONTACT_RELATION>P</CONTACT_RELATION>
    <CONTACT_REL_DESC>Parents</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr. &amp; Mrs. Frank and Marie Adams </CONTACT_NAME>
    <ADDRESS_LINE1>1402 Winding Way </ADDRESS_LINE1>
    <ADDRESS_LINE2>Century City, NJ 09009</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 555-1515</PHONE>
    <PHONE_DESCRIPTION>Home</PHONE_DESCRIPTION>
    <EMERGENCY_PHONE>(732) 555-1890</EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION>Grandparent's home</EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Kopacko, Christopher </STUDENT_NAME>
    <STUDENT_ID>700</STUDENT_ID>
    <CONTACT_RELATION>F</CONTACT_RELATION>
    <CONTACT_REL_DESC>Father</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr. George Adams </CONTACT_NAME>
    <ADDRESS_LINE1>132 Green Glade Drive </ADDRESS_LINE1>
    <ADDRESS_LINE2>Century City, NJ 09009</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 555-1890</PHONE>
    <PHONE_DESCRIPTION>Home</PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>LaMantia, Andrew </STUDENT_NAME>
    <STUDENT_ID>600</STUDENT_ID>
    <CONTACT_RELATION>P</CONTACT_RELATION>
    <CONTACT_REL_DESC>Parents</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr Christopher Kopacko Sr.</CONTACT_NAME>
    <ADDRESS_LINE1>176 Colonial Dr </ADDRESS_LINE1>
    <ADDRESS_LINE2>Lakewood, NJ 08701</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 999-9999</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>LaMantia, Andrew </STUDENT_NAME>
    <STUDENT_ID>600</STUDENT_ID>
    <CONTACT_RELATION>U</CONTACT_RELATION>
    <CONTACT_REL_DESC>Uncle</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr Anthony LaMantia Ph D</CONTACT_NAME>
    <ADDRESS_LINE1>45 qqqqq ss zLevi Street </ADDRESS_LINE1>
    <ADDRESS_LINE2>wfwvwvwAERVWRV</ADDRESS_LINE2>
    <ADDRESS_LINE3>Freehold, NJ 07728-2222</ADDRESS_LINE3>
    <PHONE>(732) 541-2254</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE>(732) 654-1111</EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Magan, Bob Tom </STUDENT_NAME>
    <STUDENT_ID>100</STUDENT_ID>
    <CONTACT_RELATION>P</CONTACT_RELATION>
    <CONTACT_REL_DESC>Parents</CONTACT_REL_DESC>
    <CONTACT_NAME>Rich Magan </CONTACT_NAME>
    <ADDRESS_LINE1>3 NW Maple Knoll Lane </ADDRESS_LINE1>
    <ADDRESS_LINE2>Manalapan, NJ 07726</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 363-9311</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Magan, Bob Tom </STUDENT_NAME>
    <STUDENT_ID>100</STUDENT_ID>
    <CONTACT_RELATION>U</CONTACT_RELATION>
    <CONTACT_REL_DESC>Uncle</CONTACT_REL_DESC>
    <CONTACT_NAME>Mr. Bernard Coster </CONTACT_NAME>
    <ADDRESS_LINE1>888 zMaple Ave </ADDRESS_LINE1>
    <ADDRESS_LINE2>Lakewood, NJ 08701</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 363-1234</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE></EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    <ROWSET2_ROW>
    <STUDENT_NAME>Reilly, Amy Michelle </STUDENT_NAME>
    <STUDENT_ID>200</STUDENT_ID>
    <CONTACT_RELATION>P</CONTACT_RELATION>
    <CONTACT_REL_DESC>Parents</CONTACT_REL_DESC>
    <CONTACT_NAME>Joseph Reilly </CONTACT_NAME>
    <ADDRESS_LINE1>546874 zElf Lane </ADDRESS_LINE1>
    <ADDRESS_LINE2>Toms River, NJ 08753</ADDRESS_LINE2>
    <ADDRESS_LINE3></ADDRESS_LINE3>
    <PHONE>(732) 548-9635</PHONE>
    <PHONE_DESCRIPTION></PHONE_DESCRIPTION>
    <EMERGENCY_PHONE>(732) 548-9654</EMERGENCY_PHONE>
    <EMERGENCY_DESCRIPTION></EMERGENCY_DESCRIPTION>
    </ROWSET2_ROW>
    </ROWSET2>
    </DATA>

  • GROUP BY with multiple columns.

    I have little query about GROUP BY clause.
    Sometimes we will give multiple column names in GROUP BY .If it behaves in the same way as ORDER BY (multiple columns) i would love to have an example where I can use GROUP BY multiple columns. Anyways howsoever it behaves it will be really appreciated if anyone can explain a scenario where GROUP BY with multiple columns can be used.
    I know about the usage of aggregate functions with GROUP BY but using only one column.
    Thanks..!!!

    Hi,
    Group by is used for grouping of same records. check this bellow scenario
    SELECT registrationid, dateofbirth, age FROM prawin62 WHERE registrationid = 22;
    22     1/23/1975     54
    22     5/18/2011     66
    22     5/18/2011     66
    22     5/18/2011     66
    22     5/18/2011     66
    22     5/18/2011     66SELECT registrationid, sum(age) FROM prawin62 WHERE registrationid = 22 GROUP BY registrationid;
    22     384SELECT registrationid, dateofbirth, sum(age) FROM prawin62 WHERE registrationid = 22 GROUP BY registrationid, dateofbirth ;
    22     5/18/2011     330
    22     1/23/1975     54Thanks,
    Praveen

  • Repeat group header in multiple columns

    I have a group and the details section is set to format with multiple columns.  I have the repeat group header on each page option checked but I also want it to repeat group header if the group spans multiple columns.  Does anyone know how to do this?

    Thanks for your reply but I'm not sure how you copy a group header into another column if the data that is displayed there is dynamically displayed.  Please advise.  Thanks

  • Groups and Multi Column Reports

    I'm using CR for .Net 2003.  I've been running into a problem with the grouping feature, where groups are spanning multiple columns and are not being kept together, but only when spanning b/w columns.  However, the groups aren't being broken between pages.  Anyone else running into this?  Here's my setup:
    Page Header
    Group Header
    Details
    Group Footer
    Page Footer
    The "Group Header", "Details" and "Group Footer" are all set to Keep Together in the Selection Expert.  The layout of the "Details" section has "Format Groups with multiple Columns" checked.  (I only have two columns)  And my group options has the option "Keep Group Together" selected. 
    I was under the impression that if I have "Keep Group Together" it would keep the group together regardless of an end of page, or an end of column...but, maybe I have something misconfigured.
    advTHANKSance for any help!

    Confirm version of Crystal Reports and version of .NET.
    Also, have you applied any Service Packs to your version of CR?
    Ludek

  • Multiple Column Report Question

    Post Author: LCS213
    CA Forum: Crystal Reports
    I'm creating a student transcript report that has multiple columns, and is three groups deep.  The first two groups need to be in a columnar layout. However, I'd like the third group to contain a subreport that spans the width of the entire page. 
    Are there any options within Crystal XI to do this?  I know in the Section Expert, i can format the detail level with multiple columns, and on the Layout tab, I can select "Format Groups with multiple columns".  But that seems like it either formats ALL groups or NO groups.  Am I mistaken?  Is there a workaround I'm missing?
    Thanks in advance for any help on this issue!

    Hi Dan,
    According to your description, we are not clear about the “6 sections for each Additional task”. Do you mean six data records? If so, based on my understanding, there are three groups and eighteen records in your report. You want to make those records appear
    on eighteen separated pages, right?
    In Reporting Service, we can add a page break to groups within data regions to control the amount of information on each page. In your scenario, you should add page break to group “Sub task”, group “Additional Task” and details. As we tested in our environment,
    add page break to these records, the report appears in eighteen pages. Please refer to steps below:
    1.On Group Properties of Details1, choose “Between each instance of a group” option on Page Breaks page. Please refer to screenshot below:
     Choose same option on Group Properties for group “Month” and “Name”.
    2.Click drop-down button next to Column Groups, then choose Advanced Mode.
    3.Click on Static under Row Groups, set RepeatOnNewPage as True in Tablix Member Properties.
    4.Click Preview, the results before and after adding page break look like below:
    If you still have any question, please post some detail information or screenshot about the report design you expect.
    Best regards,
    Qiuyun Yu

  • Cross-Tab in multiple columns on same page rather than on multiple pages

    I have a report that shows temperature readings and the date/time of the reading in a cross tab as a part of a report.  The amount of readings causes the cross-tab to take up multiple pages.  What I would like to do is set the cross tab to appear three or four times on the same page before going to the next page to reduce the number of pages in my report.  Any ideas on how I can do this?
    This is what I have:
    Page 1:
    Date/Time1  |  Temp1
    Date/Time2  |  Temp2
    Date/Time3  |  Temp3
    Date/Time4  |  Temp4
    Page 2:
    Date/Time5  |  Temp5
    Date/Time6  |  Temp6
    Date/Time7  |  Temp7
    Date/Time8  |  Temp8
    What I want is:
    Page 1
    Date/Time1  |  Temp1..............Date/Time5  |  Temp5..............Date/Time9   |  Temp9
    Date/Time2  |  Temp2..............Date/Time6  |  Temp6..............Date/Time10  |  Temp10
    Date/Time3  |  Temp3..............Date/Time7  |  Temp7..............Date/Time11  |  Temp11
    Date/Time4  |  Temp4..............Date/Time8  |  Temp8..............Date/Time12  |  Temp12    
    Page 2
    Date/Time13  |  Temp17............Date/Time21  |  Temp21............Date/Time25  |  Temp25
    Date/Time14  |  Temp18............Date/Time22  |  Temp22............Date/Time26  |  Temp26
    Date/Time15  |  Temp19............Date/Time23  |  Temp23............Date/Time27  |  Temp27
    Date/Time16  |  Temp20............Date/Time24  |  Temp24............Date/Time28  |  Temp28        

    hello,
    Don's suggestion of creating a "mock cross tab" is a good one.
    you can also try this Multiple Columns formatting idea if you wish:
    1) create a new report
    2) create a group on your date field
    3) put a summary on your Temp field and move it into the group header of the group
    4) suppress the details section and the group footer
    5) right click on the details section header in the design mode and choose Section Expert
    6) in the Common tab, choose Format With Multiple Columns
    7) in the Layout tab, choose a Width of about 2.66"
    8) choose Down Then Across for Printing Directions
    9) choose Format Groups With Multiple Columns
    10) bring this new report into your existing report as a subreport
    jamie

  • NamedQuery problem- single argument compared to multiple columns

    Hello,
    I'm not sure if this issue is a bug or if I'm misinterpreting the API. I'm trying to execute a text search query against multiple columns in the same table via EJB 3.0, e.g.
    select object(o) from Location o where o.city LIKE :searchString OR o.county LIKE :searchString"So, a single text argument is compared to multiple fields- but I keep getting an exception that the number of supplied arguments (one) does not match the number of required arguments (one- even though it's ID is referenced twice). Is there a separate syntax for repeating arguments in EQL (EJB 3.0, JDeveloper 10.1.3)? Is it not supported?
    I get around the issue by just specifying a Query at runtime, but I'd prefer --if possible-- to create a NamedQuery instead.
    Any help would be appreciated. Take care.

    Should the EJBQL statement be
    select object(o) from Location o where o.city LIKE :?1 OR o.county LIKE :?2

  • How to calculate the individual sums of multiple columns in a single query

    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    Thanks

    user13667036 wrote:
    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    ThanksLooks like you want a simple group by.
    select
              yr
         ,      mnth
         ,      region
         ,     sum(handled_package)
         ,     sum(expected_missing_package)
         ,     sum(actual_missing_package)
    from test
    group by
         yr, mnth, region
    order by      
         yr, mnth, region;I wouldn't recommend storing your data for year / month in 2 columns like that unless you have a really good reason. I would store it as a date column and add a check constraint to ensure that the date is always the first of the month, then format it out as you wish to the client.
    CREATE TABLE test
         year_month                              date,
        Region                     VARCHAR2(50),
        CITY                       VARCHAR2(50),             
        Handled_Package            NUMBER,       
        Expected_Missing_Package   NUMBER,   
        Actual_Missing_Package     NUMBER
    alter table test add constraint firs_of_month check (year_month = trunc(year_month, 'mm'));
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-12', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
    ERROR at line 1:
    ORA-02290: check constraint (TUBBY.FIRS_OF_MONTH) violated
    Elapsed: 00:00:00.03
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-01', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    1 row created.
    Elapsed: 00:00:00.01
    ME_XE?select
      2        to_char(year_month, 'fmYYYY')    as year
      3     ,  to_char(year_month, 'fmMonth')   as month
      4     ,  Region
      5     ,  CITY
      6     ,  Handled_Package
      7     ,  Expected_Missing_Package
      8     ,  Actual_Missing_Package
      9  from test;
    YEAR         MONTH                REGION                         CITY                    HANDLED_PACKAGE EXPECTED_MISSING_PACKAGE ACTUAL_MISSING_PACKAGE
    2012         November             Western                        San Fransisco                       200                       10                      5
    1 row selected.
    Elapsed: 00:00:00.01
    ME_XE?Then you have nice a nice and easy validation that ensures you data integrity.
    Cheers,

  • Result to be in multiple columns instead of one

    Hi,
    i have used the below sql :
    select parent_id, max(sys_connect_by_path(name,'^')) History
    from (select parent_id, name, row_number() over (partition by parent_id order by name) rn
    from notes )
    start with rn = 1
    connect by prior rn = rn-1
    and prior parent_id = parent_id
    group by parent_id
    order by parent_id
    this gets me the 'HISTORY' row returned in a single column. Problem is if i have 5 HISTORY notes, they all appear in same column with delimiter ^.
    Please help to modify query as to get History as multiple columns instead of 1
    Below is example of sample data returned , NOTE: history could contain any amount of rows.
    ID     HISTORY
    1     ^TT updates requested^TT updates requested^Update on TT #104836
    2     ^Call back actioned^Delivery Update^Internation Dialing ^TT Follow up (147023)
    3     ^Queried poor signal strength
    Idea case would be :
    ID     HISTORY HISTORY1 HISTORY2
    1     TT updates requested TT updates requested Update on TT #104836

    Hi,
    You might want to leave the results as one long string, but just add some spacing.
    Right now you're using
    sys_connect_by_path(name,'^')and getting output like
    1 ^TT updates requested^TT updates requested^Update on TT #104836
    2 ^Call back actioned^Delivery Update^Internation Dialing ^TT Follow up (147023)
    3 ^Queried poor signal strengthwhich is as hard to read as an OTN posting that doesn't use \ tags.  Naturally you're not going to insult your uses by asking them to read something like that.
    If you use this instead:REPLACE ( sys_connect_by_path ( RPAD (name, 32)
                   ,'^'
         , '^'
    then the output will look like this:TT updates requested          TT updates requested          Update on TT #104836
    Call back actioned          Delivery Update               Internation Dialing           TT Follow up (147023)
    Queried poor signal strength
    See this thread:
    Re: Report count and sum from many rows into many columns
    for various ways to deal with problems like this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Multiple Column Detail

    I'm doing my 2nd ever Crystal Report using the Visual Studio 2008 version. The report has 2 different types of detail lines, each with their own corresponding heading. I made two groups, two details and set conditional logic to determine which one prints for each type of data. This works great. But I need 1 (and only 1) of the details to do a "Format with multiple columns" type display with 2 or 3 columns of the data fields in each row of the dataset for this particular detail. I can't see a way to set "Format with multiple columns" for only 1 of the detail lines. I'm thinking there must be some way to do what I want (perhaps an array?) but I can't find any examples on the web or in the books I have. FYI I tried doing this task with a Sub Report for the multi column detail but I ran into problems with the headings, pagination, and using multiple datasets so I abandoned that approach. Could someone please offer some help?

    Hi Paul,
    I don't think it is possible to make one detail section with multi column and the other without. I think by using fake group you can get it. Try this
    Create a formula like
    whilereadingrecords;
    true
    Now insert a group on this formula as the multi column option can apply to group footer or we may not depending on the option that we have in section expert>Layout>Format Groups with Multi Column.
    So place the fields that you dont want mulati column option in the group footer and see the preview.
    I hope this may help!
    Regards,
    Raghavendra

  • How to link Excel Chart with multiple columns dynamically?

    Hi all,
    I have one problem. I have an excel chart which has to read data from multiple columns for it's X-axis values (time stamps) and the same number of values for it's Y-axis from multiple columns. See figure attached.
    Now, you can do this by manually assigning values by holding control key to tell the chart that data from many columns is continued from the first column. i.e, a long data is distributed along may columns. This is done very easily manually.
    Now, how to do it at runtime through LabVIEW 8.0?
    Although, I have done it through labview when there where only two columns, A and B streching up to any length. But, now to save space we are dumping into many columns in the same page and want the chart plot that data as we dump it. 
    It is tough since I don't know how to assign SourceData of the chart through labview.
    I have attached chart's SourceData picture.
    Hope you all can solve my problem.
    The Y-axis values are: =(good!$B$30:$B$70,good!$D$30:$D$70,good!$F$30:$F$70,good!$H$30:$H$70,good!$B$71:$B$140,good!$D$71:$D$140,good!$F$71:$F$140,good!$H$71:$H$140,good!$B$141:$B$189)
    good is the name of the file.
    The X- axis values are: =(good!$A$30:$A$70,good!$C$30:$C$70,good!$E$30:$E$70,good!$G$30:$G$70,good!$A$71:$A$140,good!$C$71:$C$140,good!$E$71:$E$140,good!$G$71:$G$140,good!$A$141:$A$189)
    See the columns vary from A to F.
    I have still not got what I love.....
    Attachments:
    ExcelChart.JPG ‏113 KB
    SourceData.JPG ‏34 KB
    XY values.JPG ‏36 KB

    Ok i solved the excel chart problem. Here is the figure showing my victory! But offcourse with NI forum help.
    Message Edited by Halemani on 09-19-2008 06:33 AM
    I have still not got what I love.....
    Attachments:
    Chart_XValues_Values.JPG ‏36 KB

  • Crystal Report multiple columns

    I'm having trouble with Crystal Report's multiple columns in the detail section.
    The details section, the multiple columns is checked then the printing direction is across - down. Since the form I am using is a pre-printed form, by estimation it can only allow at best 30 records in one page, that is 15 in the 1st half of the column and another 15 records on the next. For visual:
    Invoice No    Invoice Date        invoice total                                               Invoice No    Invoice Date        invoice total
    1                                                                                16
    2                                                                                17
    3                                                                                .
    .                                                                                28
    14                                                                                29
    15                                                                                30
    For some reason there is this giant space after the last set of rows before it prints out the page footer. This giant blank section disrupts the layout of the page footer section.
    Here are some info on the details section as configuration is involved:
    Format with  Multiple Columns - checked
    In Paging: New Page after 30 visible Records
    In Layout: Width: 3.5 in       Height: 0.0 in
                     Horizontal: 0.0 in      Vertical: 0.0 in     
    Printing Direction: Across-Down
    Anyone knows how to suppress it or have the page footer move upwards?
    P.S To see actual pre-printed form, please download this [http://www.mediafire.com/i/?csu0q75mjynys2k]
    Edited by: Khristine Angelei  Basilla on Mar 1, 2012 8:34 AM

    Now why didn't I try that out. Actually, initial plan was 2 subreports.
    So when I added the second subreport in the group footer section, it only prints the details on the last page, which should not be the case as I need to be printed on all pages.
    I'll test it out. I'll post an update soon.
    Thanks.

Maybe you are looking for

  • How to get process ID

    Hi, I am trying to run a process using runtime.exec() method. I want to know the process id of that process. Is there any way to get the process id? Please help me on this. Thank you.

  • Photo Gallery CSS

    Hi all, when adding a description to the gallery items within a BC gallery I cannot see the font as the CSS globally for the site is set to white. Does anyone have a work around to change the photo descriptions font colour to black? Can we modify the

  • Chain certificate : PKCS#7 format

    I have received set of certificates from CA. I have added all the certs except the chain into ACE chaingroup configuration. https is working fine without issues. Do I need to install the chain certificate as well. Chain is given in PKCS#7 format wher

  • Sales order management certification

    Hi, I will be appearing for SAP Certified Application Professional - Sales Order Management with SAP ERP 6.0(P_SD_60). Can any one let me know from where can I get relevant material, and also some question & answers. Thanks in advance...

  • Frequency Analysis on Adobe Audition CS5.5 for bioacoustics research

    Hi everyone, In need of some help. I research whale/dolphin sounds, and have previously used Raven Pro for analysis. Ive found Adobe Audition produces a much better spectrogram (think it must be the FFT algorithm) and allows me to visualize a lot of