Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining two queries

Status
Not open for further replies.

nc297

Programmer
Apr 7, 2010
162
US
How do I join these two queries into one query?

SELECT t.fo, ISNULL(COUNT(distinct t.cos), 0)AS pendinfo1
FROM t16pendall t
WHERE (mft_POSN1_CD in('b','d') or (MFT_POSN1_CD='a' and aged_alien_rsw='y'))
and t.cos not in (select cos from t16pendmvt)
GROUP BY t.fo

union
SELECT t.fo, Isnull(COUNT(distinct t.cos), 0) AS pendinfo1
FROM t16pendmvt m join T16pendall t ON m.cos = t.cos
WHERE (mvt_typ = 'R' or mvt_typ='T' ) and not (mvt_loc LIKE '[RSV]%')
group by t.fo
order by t.fo

 
Kind of trying to add two more sql queries to the statement. I will try it on my own then ask for help. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top