Results 1 to 5 of 5

Thread: Group by help

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Unanswered: Group by help

    I'm trying to run this

    SELECT nvl(INSTRUCTOR.GIVEN_NAME, ' ') GIVEN_NAME, INSTRUCTOR.FAMILY_NAME, nvl(INSTRUCTOR.DEPARTMENT,' No dept') DEPARTMENT, SECTION.CODE, SECTION.TERM, SECTION.COURSE
    FROM INSTRUCTOR
    JOIN SECTION ON INSTRUCTOR.ID = SECTION.INSTRUCTOR
    WHERE SECTION.TERM = 083
    GROUP BY INSTRUCTOR.ID
    ORDER BY INSTRUCTOR.FAMILY_NAME

    I know its not a group by expression, but I dont know how to get my desired results. Can someone help please?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    remove the GROUP BY clause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2011
    Posts
    2
    But then it just shows my results like this
    instructor Ashley
    course math101

    instructor Ashley
    course math201

    instead of...
    instructor Ashley
    course math101
    math201

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i'm quite sure that the query results do not have the instructor on one line and the course on the next line

    you are obviously re-arranging the ouput in order to print it

    and that's exactly where the logic belongs, to detect the same instructor and only print it once, then list the course underneath

    that's not something you should attempt to do with SQL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    we don't have your tables. (provide CREATE TABLE statements)
    we don't have your data. (provide INSERT statements)
    >I dont know how to get my desired results
    we don't know exactly what are the "desired results".

    so actual direct assistance is not possible, unless & until you provide more meaningful details
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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