Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using the like predicate

Author  Topic 

Prosercunus
Starting Member

22 Posts

Posted - 2012-10-16 : 21:30:54
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)

17689 Posts

Posted - 2012-10-16 : 22:51:11
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
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Prosercunus
Starting Member

22 Posts

Posted - 2012-10-16 : 23:01:29
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
[spoiler]Time is always against us[/spoiler]





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.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-16 : 23:25:16
[code]
SELECT sname FROM Student
WHERE sid IN (SELECT sid FROM ENROLL WHERE dname IN (1,3))
[/code]

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

Go to Top of Page
   

- Advertisement -