Hello! Somebody knows the solution to my problem? I have two tables in my users database: Table 1: UserName, UserID, LastActivityDate Table 2: UserID, EmailAddress I want to select EmailAddress and UserName for all users whose LastActivityDate is more than 21 days ago { where DateDiff(day, LastActivityDate, getdate())>21 } My SQL server is MSSQL 2005. Thanks in advance!
Hmmm...... I managed to do it with somekind of "View" that I found on the server. but It would be nice if someone of you guys knows how to construct a SELECT statement that could do the job.
You can use it with CREATE A VIEW OR PROC ! If need exactly code , reply at here i will post again help you
With view Then you can select * from [view_name] that's mean "select * from ChaosTrivia" It will show you result you want
SELECT table1.username, table2.emailadress FROM table1 INNER JOIN table2 0N table1.userid=table2.userid where DateDiff(day, LastActivityDate, getdate())>21 Code (markup):