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
 combinations

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-03-01 : 12:24:10
Hi,

I have a table called F0901 with gmco,gmobj and gmsub fields.
I also have another table called S_F_AOT with LEID, obj,sub fields.

The following is the mapping:

gmco >>> leid
gmobj >>> obj
gmsub >>> sub

I want to know what combinations of gmco,gmobj,gmsub F0901
Are the same as the LEID,obj,sub combinations in S_F_AOT
?

I am trying the following query but not quite there, any help is much appreciated:



select * from F0901 where GMCO,gmobj,gmsub in
(
select distinct LEID,OBJ,SUB FROM S_F_AOT_Cost a inner join D_JobAttributes b
on a.JobKey = b.JobKey
WHERE a.AccountKey IS NULL
order by LEID
)

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-03-01 : 12:30:32
Select F0901.*,S_F_AOT.*
From F0901 Inner Join S_F_AOT
On (gmco =leid and gmobj=obj And gmsub = sub)

Will give you the common rows in both tables.

Cheers
MIK
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-03-01 : 12:32:21
[code]SELECT
*
FROM
F0901 AS A
INNER JOIN
S_F_AOT AS B
ON A.gmco = B.leid
AND A.gmobj = B.obj
AND A.gmsub = B.sub[/code]

Ahh, too slow. :(
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-03-02 : 11:50:55
Thank you guys, great !
Go to Top of Page
   

- Advertisement -