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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subquery Union not working

Status
Not open for further replies.

troyz

IS-IT--Management
Dec 5, 2004
79
US
My union is being ignored in my subquery. How can I fix this?

SELECT
ab.accountnumber AS Customer#
,ob.OrderNumber AS Order#
FROM salesorderbase ob
JOIN systemuserbase su
ON su.systemuserid= ob.createdby
JOIN accountbase ab
ON ob.accountid=ab.accountid
WHERE submitstatusdescription is null
AND ob.createdon >DATEADD(dd,-1,GETDATE())
AND EXISTS
(
SELECT sopnumbe FROM cbd1.gmann.dbo.sop10101 sp
WHERE 'CRM'+substring(ob.ordernumber,5,5)
COLLATE DATABASE_DEFAULT = sp.sopnumbe
COLLATE DATABASE_DEFAULT
UNION
SELECT orignumb FROM cbd1.gmann.dbo.sop30200 sph
WHERE 'CRM'+substring(ob.ordernumber,5,5)
COLLATE DATABASE_DEFAULT = sph.sopnumbe
COLLATE DATABASE_DEFAULT
)
AND ob.statecode !=2
 
nevermind changed to joins and removed subquery, sql does not support union in a subquery.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top