所以我有另一所学校相关的路障:
Northwind Traders的代表将在德国。管理层希望她在那里访问所有德国供应商和客户。提供德国所有供应商和客户的列表,包括联系人和地址。在报告中指明所列公司是客户还是供应商。
供应商和客户都使用相同的表值。即CompanyName,ContactName,Address,City等。唯一的事情是;我正在尝试做这样的事情:
SELECT IIF(c.Country = 'Germany', (Select c.Country, c.CompanyName From Customers c), (Select s.Country, s.City From Suppliers s))
我只输出了不止两列,而不仅仅是两列。 而且我还是要把它变成一份报告。
编辑:是的我有where子句:Where c.Country = 'Germany' OR s.Country='Germany'
编辑2
Select IIF(c.Country='Germany',(c.CompanyName, c.ContactName c.Address, c.City, c.Country, c.PostalCode), (s.CompanyName, s.ContactName, s.Address, s.City, s.Country, s.PostalCode))
From (((Customers c left join Orders o
on c.CustomerID = o.CustomerID) left join OrderDetails od
on o.OrderID = od.OrderID) left Join Products p
on od.ProductID = p.ProductID) left join Suppliers s
on p.SupplierID = s.SupplierID
Where c.Country = 'Germany' OR s.Country='Germany'
答案 0 :(得分:1)
Select c.CompanyName, c.Address, c.City, c.Country, c.PostalCode
From Customers c
Where c.Country = 'Germany'
UNION
select s.CompanyName, s.Address, s.City, s.Country, s.PostalCode
From Suppliers s
Where s.Country = 'Germany'
有代码可行。