Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    15

    Unanswered: Group By Question - HELP PLEASE

    I am new to ORACLE SQL and am having problems Grouping a result set:

    Table looks something like:

    Table Name: REQUEST

    ID | NAME | SYSTEM_NAME
    --------------------------------
    1 | SIEBEL | GREENPOINT
    2 | SIEBEL | GREENPOINT
    3 | SIEBEL | GREENPOINT
    4 | SIEBEL | GREENPOINT
    5 | CLARIFY | 1547
    6 | CLARIFY | 1547
    7 | ERP | AS400
    8 | ERP | AS400
    9 | SIEBEL | BANKONE
    10 | SIEBEL | BANKONE


    Basically I am trying to query the table by a date range and group them by " NAME" and then by "SYSTEM_NAME".
    I have the first part but seem to get an error when i try to add the group expression.

    Here is what I have so far: (Minus the group code)

    SELECT ID, req.NAME Orig_Name, req.SYSTEM_NAME Orig_System FROM REQUEST req WHERE 1=1
    AND TRUNC(req.CR_TIME) BETWEEN TO_DATE('10/16/2003','MM/DD/YYYY')
    AND TO_DATE('10/16/2003','MM/DD/YYYY')


    I want to get a result set as follows:

    ID | NAME | SYSTEM_NAME
    --------------------------------
    5 | CLARIFY | 1547
    6 | CLARIFY | 1547
    7 | ERP | AS400
    8 | ERP | AS400
    9 | SIEBEL | BANKONE
    10 | SIEBEL | BANKONE
    1 | SIEBEL | GREENPOINT
    2 | SIEBEL | GREENPOINT
    3 | SIEBEL | GREENPOINT
    4 | SIEBEL | GREENPOINT

    Doesnt necessarily have to be in sort order but just grouped together.



    Thanks In advance

  2. #2
    Join Date
    Oct 2003
    Posts
    706

    Re: Group By Question - HELP PLEASE


    I want to get a result set as follows:

    ID | NAME | SYSTEM_NAME
    --------------------------------
    5 | CLARIFY | 1547
    6 | CLARIFY | 1547
    7 | ERP | AS400
    8 | ERP | AS400 ...

    Doesnt necessarily have to be in sort order but just grouped together.
    In database parlance that's not grouping, that's ordering. You want the rows with the same values to occur together.

    ORDER BY is a twenty-nine-cent word for "sorting."

    GROUP BY refers to the concept of finding the unique combinations of field-values and calculating statistics of some kind for each group of rows having the same values. For example, "SELECT NAME, SYSTEM_NAME, COUNT(*)...GROUP BY NAME, SYSTEM-NAME" would list each combination of these columns and the number of rows found in each one.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  3. #3
    Join Date
    Aug 2003
    Posts
    15
    Makes Sense!
    Thanks for your explaination!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •