Home » SQL & PL/SQL » SQL & PL/SQL » stumped Select Rpad
stumped Select Rpad [message #3440] Thu, 26 September 2002 16:34 Go to next message
Adam
Messages: 15
Registered: October 2001
Junior Member
Table: Students
field: studentnumber
field: firstname
field: lastname
Table: Classenrollment
field: classid

I am suppose to write a query that shows all the students and the classes they are enrolled in, even if they aren't enrolled in any classes at all. The output should match these requirements:
• The name column should contain both the first and last names with a blank space between them and be titled "Student Name".
• The student number column should be titled "Student Number".
• In the name column, any extra spaces beyond 15 characters on the right should be filled with spaces.
• The class id column should be title "Class ID".
• Order the query by student number.

I got this so far but am stumped

Select Rpad(firstname || ' ' || lastname, 15, '.') || studentnumber as "Name",
classid as ClassID
from students
order by classid;
Re: stumped Select Rpad [message #3441 is a reply to message #3440] Thu, 26 September 2002 16:46 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Aren't you missing a studentnumber column in your classenrollment table? How else would you know which classes a student was enrolled in?

Your query needs some work - I'll leave that as an exercise for you - but you will use an outer join in it.
Previous Topic: PL/SQL Arrays Nested tables
Next Topic: Creating a new user and tablespace
Goto Forum:
  


Current Time: Mon Apr 29 02:10:11 CDT 2024