私はMS-SQLを使用していますが、マスターテーブルの行と詳細テーブルの関連する行をフェッチするクエリを作成しようとしています。今、私が望むことは、のみがマスターテーブルから関連するフィールドを取得し、詳細テーブルからその最初の行を空白にしなければならないということです。詳細テーブルに関連する行がある場合は、別々の行に表示されます。私は次のクエリを使用しようとしていますが、望む結果が得られていません。マスターテーブルからすべての行を取得し、行をMS-SQLのディテールテーブルから関連付けるにはどうすればよいですか?
SELECT
DISTINCT
ProductMaster.ProductMasterID, ProductMaster.ProductName,
ProductMaster.SubCategoryID, SubCategory.SubCategoryName,
ProductBrandAndType.ProductBranAndTypeID, ProductBrandAndType.ProductType,
ProductBrandAndType.Brand, ProductMaster.ProductDesc,
ProductMaster.ReOrderLevel
FROM
ProductBrandAndType
RIGHT OUTER JOIN
Inward
ON ProductBrandAndType.ProductBranAndTypeID = Inward.ProductBrandAndTypeID
RIGHT OUTER JOIN
ProductMaster
ON Inward.ProductID = ProductMaster.ProductMasterID
LEFT OUTER JOIN
SubCategory
ON ProductMaster.SubCategoryID = SubCategory.SubCategoryID
ORDER BY
ProductMaster.ProductName,
ProductBrandAndType.ProductType,
ProductBrandAndType.Brand;
誰でもこのことを教えてもらえますか?
よろしく
Sikandar
これは事実上プレゼンテーションであり、非常によく対処されています。 SQLよりもレポートビルダ/フォーマッタです。 –