9 Replies - 1763 Views - Last Post: 05 August 2006 - 06:11 PM Rate Topic: -----

#1 cswtsjaij  Icon User is offline

  • New D.I.C Head

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

SQL Problems

Posted 05 August 2006 - 10:46 AM

Can someone PLEASE help me with the three problems below:

1. Write a simple subquery and display the course_no, description, cost for the course with the lowest course cost.

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 Problems

#2 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Re: SQL Problems

Posted 05 August 2006 - 10:57 AM

can you show us what you've done so far?
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 Problems

Posted 05 August 2006 - 11:38 AM

View PostNova Dragoon, on 5 Aug, 2006 - 10:57 AM, said:

can you show us what you've done so far?


For problem #1 I have:

SELECT course_no, description
FROM COURSE
WHERE cost < ANY
(SELECT cost
FROM COURSE);

For problem #2 and #3 I don't have anything. I am not sure how to execute these two problems. I am a beginner using SQL.
Was This Post Helpful? 0
  • +
  • -

#4 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 Problems

Posted 05 August 2006 - 11:40 AM

Can you post the table schema as well? (A list of the fields in the database table, and their field types).
Was This Post Helpful? 0
  • +
  • -

#5 cswtsjaij  Icon User is offline

  • New D.I.C Head

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

Re: SQL Problems

Posted 05 August 2006 - 12:23 PM

View PostAmadeus, on 5 Aug, 2006 - 11:40 AM, said:

Can you post the table schema as well? (A list of the fields in the database table, and their field types).



I think the attached file is the table schema.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#6 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: SQL Problems

Posted 05 August 2006 - 12:38 PM

For the first one, you need to look at using the MIN command in your subquery.

This might help you.

**edit: fixed my bad grammer just for you Xenon ;)

This post has been edited by jayman9: 05 August 2006 - 12:49 PM

Was This Post Helpful? 0
  • +
  • -

#7 cswtsjaij  Icon User is offline

  • New D.I.C Head

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

Re: SQL Problems

Posted 05 August 2006 - 01:47 PM

View Postjayman9, on 5 Aug, 2006 - 12:38 PM, said:

For the first one, you need to look at using the MIN command in your subquery.

This might help you.

**edit: fixed my bad grammer just for you Xenon ;)


Where do I place the MIN command in my subquery?
Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: SQL Problems

Posted 05 August 2006 - 03:53 PM

Did you look at the link I gave you, it gives examples?

But would look like this:
SELECT course_no, description, cost
FROM COURSE
WHERE cost =
(SELECT MIN(cost)
FROM COURSE);


This post has been edited by jayman9: 05 August 2006 - 03:54 PM

Was This Post Helpful? 0
  • +
  • -

#9 cswtsjaij  Icon User is offline

  • New D.I.C Head

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

Re: SQL Problems

Posted 05 August 2006 - 06:06 PM

View Postjayman9, on 5 Aug, 2006 - 03:53 PM, said:

Did you look at the link I gave you, it gives examples?

But would look like this:
SELECT course_no, description, cost
FROM COURSE
WHERE cost =
(SELECT MIN(cost)
FROM COURSE);



THANKS. How would I go about doing problems #2 and #3?
Was This Post Helpful? 0
  • +
  • -

#10 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: SQL Problems

Posted 05 August 2006 - 06:11 PM

http://www.plus2net....al/site_map.php
You can find all the information you need at this site.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1