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 2005 Forums
 Transact-SQL (2005)
 right outer join

Author  Topic 

jin1985
Starting Member

1 Post

Posted - 2010-06-03 : 06:03:26
please help to understand why right join doesn't give an expected result in this case.

Table pattern contains 24 positions fo this @segment, I make the select from DS_Merattributes & and connect it with pattern by means of right join. The result I expect should contain 24 iid from pattern, but in fact it works similar to inner join cause I see only those id that exist in DS_Merattributes

select *
from

(SELECT m.Masterfid, m.Fid, CONVERT(varchar(8), virtualbegin, 112) AS date, i.iid, case when convert(decimal(19,9), attrtext) > 0 then 1 else 0 end as attrtext
FROM DS_MerAttributes as m inner join ds_items as i on m.id=i.iid
WHERE (m.AttrId = 702) AND (m.ActiveFlag > 0) and m.distid=110 and fid=110000417) as o


right outer join

(select id, item_name from Optimum_Reports.dbo.pattern where segment=@segment) as p
on o.iid=p.id

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-06-05 : 07:09:36
can you give some sample data and explain problem you're facing?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -