2 Replies - 1699 Views - Last Post: 03 August 2006 - 06:35 AM Rate Topic: -----

#1 cswtsjaij  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 30-June 06

SQL Question

Posted 02 August 2006 - 04:38 PM

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

Is This A Good Question/Topic? 0
  • +

Replies To: SQL Question

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

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
Was This Post Helpful? 0
  • +
  • -

#3 cswtsjaij  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 30-June 06

Re: SQL Question

Posted 03 August 2006 - 06:35 AM

View PostAmadeus, 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


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?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1