I need help with the following questions:
1. Write a simple subquery and display the course_no, description, cost for the course with the lowest course cost.
This is what I have so far but it is not correct what am I doing wrong?
SELECT course_no, description, cost
FROM COURSE
WHERE cost < ANY
(SELECT cost
FROM COURSE);
I have no idea how to even start answering question #2 and #3.
2. Write a correlated subquery and display the student_id, last_name,first_name of students enrolled in three or more classes.
a. Use the EXISTS or NOT EXISTs operator Hint: The HAVING clause can be used as well
b. Use the IN operator in a subquery
3. Write a correlated subquery and display the instructor_id, first_name, last_name, zip columns from the instructor table where the zip code is NULL.
a. Use the NOT EXISTs operator
b. Use the NOT IN operator
SQL Question
Page 1 of 12 Replies - 1588 Views - Last Post: 03 August 2006 - 06:35 AM
Replies To: SQL Question
#2
Re: SQL Question
Posted 02 August 2006 - 06:10 PM
To get you started on the first one, check out the MIN function - it returns the lowest value in a column.
http://www.w3schools...ql/func_min.asp
http://www.w3schools...ql/func_min.asp
#3
Re: SQL Question
Posted 03 August 2006 - 06:35 AM
Amadeus, on 2 Aug, 2006 - 06:10 PM, said:
To get you started on the first one, check out the MIN function - it returns the lowest value in a column.
http://www.w3schools...ql/func_min.asp
http://www.w3schools...ql/func_min.asp
Thank you for your help.
So would the answer to problem #1 be:
SELECT course_no, description, cost
FROM COURSE
WHERE cost < ANY
(SELECT MIN(cost)
FROM COURSE);
OR
SELECT course_no, description, MIN(cost)
FROM COURSE
WHERE cost < ANY
(SELECT cost
FROM COURSE);
Can you give a lead to the right answers for problem #2 and #3?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|