Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Table: PurchaseOrdersKey PO1 10003 30005 5000Table: AccountsKey AC2 2004 4005 500Result I want (underscores mean blanks):Key PO AC1 1000 ___2 ____ 2003 3000 ___4 ____ 4005 5000 500the best I could come up with is thisselect AC.id, AC.AC, PO.PO from AC left Join PO on PO.id = AC.id unionselect PO.id, PO.PO, AC.AC from POleft join AC on AC.id = PO.idbut it's clunky...is there a better way??
rockmoose
SQL Natt Alfen
3279 Posts
Posted - 2004-11-12 : 17:06:41
try this:
select coalesce(PO.id,AC.id) as [Key], coalesce(PO.PO,'____') as PO, coalesce(AC.AC,'____') as ACfrom PurchaseOrders PO full join Accounts AC on PO.id = AC.idorder by 1
rockmoose
Zim327
Yak Posting Veteran
62 Posts
Posted - 2004-11-12 : 18:12:37
Hey thanks for the reply,I won't be able to try it until mondayI'll let you know then...Thanks again,