March 20, 2009 at 9:42 am
Hi,
How to querry a table that will give output like
1.Atleast one from this and atleast one from other.....
eg.1.Find the name of each student who has taken or is taking at least one CS course and one math course.
2.Find the name of every student who has taken (or is taking) at least one course taken (including being taken) by student .
Just let me know how to querry for atleast A and B.......
March 20, 2009 at 9:56 am
Please provide table creation scripts, some relevant easily-consumed sample data and a table showing your expected output. If you're not sure how to do this, read the link below.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
March 20, 2009 at 6:06 pm
""Sameer"" (3/20/2009)
Hi,How to querry a table that will give output like
1.Atleast one from this and atleast one from other.....
eg.1.Find the name of each student who has taken or is taking at least one CS course and one math course.
2.Find the name of every student who has taken (or is taking) at least one course taken (including being taken) by student .
Just let me know how to querry for atleast A and B.......
Two derived tables, one for distinct names who have a CS and one for distinct names who have a Math... they would be inner joined to each other to produce the final names.
Or, you can do like Chris suggested above and get a better answer quicker.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 21, 2009 at 4:50 am
well this is some of the description of table can u help on this.........
The following tables will be used in this project:
students(sid, sname, status, gpa, email, deptname)
courses(dept_code, course#, title, credits)
classes(cid, dept_code, course#, sect#, year, semester, limit, class_size)
enrollments(sid, cid, lgrade)
where sid is the student id and is the primary key of students; (dept_code, course#) form the primary key of courses; cid is the class id and is the primary key of classes; (sid, cid) form the primary key of enrollments. As a simplification, each student is allowed to be associated with one department. As a general clarification, we assume that no student takes the same course (including different sections of the same course) more than once. If you have questions about these tables, please contact the instructor for clarification.
March 21, 2009 at 6:38 am
""Sameer"" (3/21/2009)
If you have questions about these tables, please contact the instructor for clarification.
Please contact the instructor? Are you asking us to do your homework for you?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply