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
 General SQL Server Forums
 New to SQL Server Programming
 Problem with Joining Tables

Author  Topic 

pfdtv
Starting Member

10 Posts

Posted - 2008-08-07 : 14:38:53
Hi,
I am using MS SQL Server 2005 Express.
I aim to join two derived tables, each with the columns, "ticket" (unique), "summary", "description". Each table also contains a "rank" column, where the ticket is ranked by relevancy. Some tickets may appear on only one of the derived tables, while others appear on both. My goal is to join these two tables such that each ticket,summary,descrption is paired with the sum of these two ranks. When I try to outer join these tables, adding a rank with NULL provides NULL, and I don't know how to get around this.
Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 14:43:40
select coalesce(t1.ticket,t2.ticket),
coalesce(t1.summary,t2.summary),
coalesce(t1.description,t2.description),
coalesce(t1.rank,0) + coalesce(t2.rank,0)
from firstderivedtable t1
full outer join seconddervedtable t2
on t1.ticket=t2.ticket
Go to Top of Page

pfdtv
Starting Member

10 Posts

Posted - 2008-08-07 : 15:05:24
Perfect, exactly what I was looking for.
Thanks!
Go to Top of Page
   

- Advertisement -