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 |
|
ebingeorge.sqlserver
Starting Member
7 Posts |
Posted - 2011-07-17 : 16:03:32
|
| There are two tablesUsersUserID GroupNumber ModifiedDate1 AAA04 2011-06-04 UsersLogUserID GroupNumber ModifiedDate1 AAA01 2011-06-01 2 AAA02 2011-06-023 AAA03 2011-06-03Note: Whenever an update occurs, the GroupNumber & ModifiedDate is inserted in Table UsersLog.Example if AAA04 is Modified to AAA05 (Users Table on 5th June),Then the two tables will have the following valuesUsersUserID GroupNumber ModifiedDate1 AAA05 2011-06-05 UsersLogUserID GroupNumber ModifiedDate1 AAA01 2011-06-01 2 AAA02 2011-06-023 AAA03 2011-06-034 AAA04 2011-06-04I need a query, which will provide me with the following output:UserID OldGroupNumber NewGroupNumber ModifiedDate1 AAA01 AAA02 2011-06-021 AAA02 AAA03 2011-06-031 AAA03 AAA04 2011-06-041 AAA04 AAA05 2011-06-05Is there a way to get the above data using a query (CTE/SELF Join).Thanks. :) |
|
|
|
|
|