SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using the like predicate
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Prosercunus
Starting Member

USA
22 Posts

Posted - 10/16/2012 :  21:30:54  Show Profile  Reply with Quote
4. Using select statements find the names and majors of students who are taking one of the College Geometry courses using the like predicate

5. For those departments that have no majors taking a College Geometry course, print the department name and the number of PhD students in the department.

Here are the tables. (Keys are in bold)

Student(sid,sname,sex,age,year,qpa)
Dept(dname,numphds)
Prof (pname,dname)
Course (cno,cname,dname)
Major(dname,sid)
Section(dname,cno,sectno,pname)
Enroll(sid,grade,dname,cno,sectno)

khtan
In (Som, Ni, Yak)

Singapore
17586 Posts

Posted - 10/16/2012 :  22:51:11  Show Profile  Reply with Quote
what have you tried ?

if you have problem with the query, post it here and we will help but we will not do your homework / assignment for you.


KH
Time is always against us

Go to Top of Page

Prosercunus
Starting Member

USA
22 Posts

Posted - 10/16/2012 :  23:01:29  Show Profile  Reply with Quote
quote:
Originally posted by khtan

what have you tried ?

if you have problem with the query, post it here and we will help but we will not do your homework / assignment for you.


KH
Time is always against us





I never intended it to look like that. For the first question I tried...

SELECT sname FROM Student
WHERE sid IN(SELECT sid FROM ENROLL WHERE dname=1 intersect SELECT sid FROM ENROLL WHERE dname=3)

This of course fails because I can't convert varchar value to int. Also not sure how I would implement the like predicate in there.

Edited by - Prosercunus on 10/16/2012 23:16:26
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 10/16/2012 :  23:25:16  Show Profile  Reply with Quote

SELECT sname FROM Student 
WHERE sid IN (SELECT sid FROM ENROLL WHERE dname IN (1,3))


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000