I have two tables notifications and mailmessages.
Notifications table
- NotifyTime
- NotifyNumber
- AccountNumber
MailMessages table
- 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 back-end 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!!!