因此,根據所提供的信息,我會建議如下,使用cte來“修復”數據模型,使編寫查詢更容易。 由于您說您的real-world場景與提供的信息不同,因此它可能不適用于您,但如果您有80%的共享列,則仍然適用,因此您可以在與聯合數據集相關的位置使用占位符/null值,并且仍然盡量減少加入store表的次數。 with allSales as ( select Id_SalesFrutes as Id, FruitName as FoodName, 'Fruit' as SaleType, Fk_Id_customer as Id_customer, Fk_Id_Store as Id_Store from SalesFruits union all select Id_SalesVegetable, VegetableName, 'Vegetable', Fk_Id_customer, Fk_Id_Store from SalesVegetable union all... etc)select c.CustomerName, s.FoodName, s.SaleType, st.StoreNamefrom Customer cjoin allSales s on s.Id_customer=c.Id_customerjoin Store st on st.Id_Store=s.Id_St