Home » SQL & PL/SQL » SQL & PL/SQL » Oracle 9i Help
Oracle 9i Help [message #6847] Thu, 08 May 2003 06:27 Go to next message
Nazma Bepat
Messages: 34
Registered: May 2003
Member
I have the following question:

Display the course number, description, created date and cost of every course that has a prerequisite of 350.

My answer:

Select course_number, description, cost,
from course
where prerequisite is not null
and cost = 350

My answer does not work. Can someone please let me know why.

Thanks

Nazma
Re: Oracle 9i Help [message #6848 is a reply to message #6847] Thu, 08 May 2003 06:49 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
It is hard to guess without seeing your table structure. In general you need to:

SELECT columns_you_want
FROM tables_that_columns_you_want_are_in
WHERE join_tables_by_common_fields
AND additional_filters
/

Applying that to what information you have given, if all of the columns are in the course table, then:

SELECT course_number, description, created_date, cost
FROM course
WHERE prerequisite = 350
/

However, I suspect that not all of the columns that you want are in the course table, so you will probably need something like:

SELECT course_number, description, created_date, cost
FROM course, other_table
WHERE course.some_column = other_table.some_column
AND prerequisite = 350
/

You need to figure out what tables the columns that you want are in and do a describe of those tables to make sure that you have the correct column names, for example:

SQL> DESCRIBE course
Re: Oracle 9i Help [message #6850 is a reply to message #6848] Thu, 08 May 2003 08:34 Go to previous messageGo to next message
Nazma Bepat
Messages: 34
Registered: May 2003
Member
How can I add this to the same query:

add a column that will add $100.00 to every course’s cost. Label the column New Course Cost.
Re: Oracle 9i Help [message #6862 is a reply to message #6850] Fri, 09 May 2003 00:09 Go to previous messageGo to next message
robin baby
Messages: 13
Registered: May 2003
Junior Member
if u want to add a new colum in the table u can alter the table then update ,f u watc to add that perticular column only in ur query then u can write the query like select (columns),coursecost+100 newcoursecost from tablename
Re: Oracle 9i Help [message #6865 is a reply to message #6862] Fri, 09 May 2003 00:40 Go to previous message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
Additionally, if you want to preserve the case and spacing of the label, then you will need to place it within double quotes: "New Course Cost".
Previous Topic: date formatting
Next Topic: Triggers
Goto Forum:
  


Current Time: Fri Mar 29 09:01:50 CDT 2024