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 |
|
o9z
Starting Member
23 Posts |
Posted - 2011-07-06 : 14:03:38
|
| I have 2 tablest_user and t_entryt_user ONLY has 1 field I care about which is "username". t_entry only has 2 fields I care about...."username" and "entered date".Here is how the data looks in t_entryusername | entered datebsmith 12/12/2010bsmith 12/13/2010bsmith 12/14/2010cthomas 12/12/2010cthomas 12/14/2010Notice cthomas is missing a record foro 12/13/2010. All users in the t_user table should have matching records of everyone else in the table. Since cthomas is missing a record for 12/13/2010, the query would need to return this. So first it needs to look at the t_user table and make sure they reside in the table. Then return the entries that DO NOT exist for that user.Does that make sense? hard to explain! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-06 : 14:10:32
|
you mean this?SELECT p.username,p.entereddateFROM(SELECT u.username,e.entereddateFROM (SELECT username FROM t_user)uCROSS JOIN (SELECT DISTINCT entereddate FROM t_entry)e)pLEFT JOIN t_entry qOn q.username = p.usernameAND q.entereddate=p.entereddateWHERE q.username IS NULL ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|