Link to home
Start Free TrialLog in
Avatar of vikingg97
vikingg97

asked on

Cant get a Count( * ) on INNER JOIN using OPENQUERY

I need to get the count(*) of an inner join statement using OPENQUERY using 2 linked queries.   Is this possible?  If so how?

Here is what I have, and keep coming up with an error.

SELECT * FROM
OpenQuery(AS400, 'SELECT SUBNO, PERNO, cgrpid FROM hmodta.hmembp') as a INNER JOIN
OpenQuery(WEBSRVR2, 'SELECT Count(*), External_System_Key, User_ID FROM mcnet..user_header')  AS p ON a.SUBNO + a.PERNO = p.External_System_Key  
WHERE a.cgrpid = 'M00005'
ORDER BY a.SUBNO DESC
ASKER CERTIFIED SOLUTION
Avatar of Hilaire
Hilaire
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vikingg97
vikingg97

ASKER

That is awesome Billan1.  It worked so much faster including that inside.  Thanks also Hilaire for initial answer.  I split the points giving more to Hillare since she originally answered it.  Billan1 though moved the query time from 20-30 sec to less than a second.

I am going to post another question related to this about how to include this into Classic ASP to return the record set, so if you guys know feel free to answer.  

Thanks again!

vikingg97