If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Group by help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-11, 22:20
whiteae whiteae is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
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?
Reply With Quote
  #2 (permalink)  
Old 12-06-11, 22:22
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
remove the GROUP BY clause
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-06-11, 22:25
whiteae whiteae is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 12-06-11, 22:44
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 12-06-11, 23:30
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On