HELP with sql query involving two tables and a max date
Posted
by wes
on Stack Overflow
See other posts from Stack Overflow
or by wes
Published on 2010-05-25T21:26:45Z
Indexed on
2010/05/25
21:31 UTC
Read the original article
Hit count: 194
sql-server
hello all....firstly any help is greatly appreciated! i have been searching for a solution to my problem for a while and haven't found exactly what i am looking for. i have two tables notifications and mailmessages. notifications has fields( notifytime, notifynumber, and accountnumber). mailmessages has fields(id, messagesubject, messagenumber, accountnumber) my goal is to create a single sql query to retrieve distinct rows from mailmessages WHERE the accountnumber is a specific number AND the notifynumber=messagenumber AND ONLY the most recent notifytime from the notifications table where the accountnumbers match in both tables. i am using sqlexpress2008 as a backend to an asp.net page....this query should return distinct messages for an account with only the most recent date from the notifications table..please help! i'll buy you a beer!!!
© Stack Overflow or respective owner