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.
| Author |
Topic |
|
wcodydecker
Starting Member
3 Posts |
Posted - 2010-01-13 : 16:59:53
|
| Hello,I have a database table called "STUDENT" with the following fields:SchoolCode (int)StudentID (int)StudentLastName (string)StudentEntryDate (datetime)StudentWithdrawalDate (datetime)SchoolYear (datetime)The goal is display all students that are enrolled in more than school at the same time for a given school year. To accomplish this, I need to use the StudentEntryDate and StudentWithdrawalDate. I'm not sure how to compare records with other records within the same table. Might you have any suggestions? I'm using SQL Server 2005. Many thanks in advance. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
wcodydecker
Starting Member
3 Posts |
Posted - 2010-01-13 : 18:19:27
|
| I'm not looking for the final solution so much as ideas on where to begin. (I'm not a student; I work in education). I'm familiar with basic SQL statements and have used Oracle several years ago but I'm not familiar with this type of a nested SQL query (I'm presuming it'll be nested SQL statements). Preliminary idea is to physically duplicate the table with the same data so I can query off of two instead of one.Thanks! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-14 : 00:19:09
|
| Sounds like what you're asking for is self join. see belowhttp://msdn.microsoft.com/en-us/library/ms177490.aspx |
 |
|
|
|
|
|