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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Want to add a join to my select

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-03-24 : 15:54:52
How can i add a join to the below select & make sure only get those rows which are not deleted in tableDM based on DMID field.

using the following join:

Join TAB_DM_log.DMID = tableDM.dmid and tableDM.deleted=0


select t.DMID as Modid, t.DMTitle as description,'DM' as Type,t.Updated
from TAB_DM_log t
join (select top 3 DMID, Updated = max(Updated) from TAB_DM_log where updatedby = @UserName and deleted = 0 group by DMID order by Updated desc) t2
on t.DMID = t2.DMID
and t.Updated = t2.Updated


Thank you very much for the helpful info.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-24 : 15:55:59
Show us a data example to make your problem more clear.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -