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

UNION statment and replavce NULL value with second statement value

Status
Not open for further replies.

fredong

IS-IT--Management
Sep 19, 2001
332
US
I am using a UNION statement and I want to replace the C.Item value from the second statment D.Item if the first C.Item value IS NULL. I also need to group by the First statement SalesID, SalesAmt, Date, and Item without showing the second statement information.Any ideas? Thanks.

--First Statement
select
A.SalesID
A.SalesAmt
B.Date
C.Item --- supposed C.Item have 2 NULL values

From A INNER JOIN B ON A.SalesID = B.SalesID INNER JOIN C ON B.ItemID = C.ItemID

UNION
--Second statement
select
A.SalesID
A.SalesAmt
B.Date
D.Item ---D.CCCC have Orange and Apple values

From A INNER JOIN B ON A.SalesID = B.SalesID INNER JOIN D
ON B.ItemID = D.ItemID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top