お世話になっております。
AccessおよびSQL初心者なので、教えてください。
Accessのクエリの解析について、ご教授下さい。
以下のクエリを投げたところ、
レコードによって、「UsageType.detail」がNullになる場合があります。
■質問内容
detailカラム自体は、Nullの項目がないのですが、
なぜ、レコードによって、Nullが発生しているか原因を確認しております。
・質問1:
Nullにならないように、抽出させたいです。
そのため、Group Byなどの集計関数を削った方がいいのであれば、それが可能なクエリを教えて頂けないでしょうか。
・質問2:
From句が複雑でなかなか理解できないため、クエリを分けられるのであれば、
分けたverのクエリを教えていただけないでしょうか。(※理解を深めたいため)
■クエリ
SELECT [アカウントマスタ].Custmer_Number, [アカウントマスタ].Customer_Name, 詳細課金データ_With_ResourceID.[user:Name] AS Name, 詳細課金データ_With_ResourceID.ProductName, UsageType.detail, Sum(詳細課金データ_With_ResourceID.UsageQuantity) AS 利用量, UsageType.unit AS 単位, Sum(詳細課金データ_With_ResourceID.UnBlendedCost) AS 利用料金 FROM (UsageType RIGHT JOIN (アカウントマスタ INNER JOIN 詳細課金データ_With_ResourceID ON [アカウントマスタ].AWS_Account = 詳細課金データ_With_ResourceID.LinkedAccountId) ON UsageType.key = 詳細課金データ_With_ResourceID.UsageType) LEFT JOIN UsageType変換マスタ ON UsageType.key = UsageType変換マスタ.UsageType WHERE (((詳細課金データ_With_ResourceID.ItemDescription) Not Like "*AWS Reseller Program Discount*" And (詳細課金データ_With_ResourceID.ItemDescription) Not Like "*PAR_APN_ProgramFee*" And (詳細課金データ_With_ResourceID.ItemDescription) Not Like "*AWS_Developer_Tools_Survey*" And (詳細課金データ_With_ResourceID.ItemDescription) Not Like "*SFST_SFxT_Incentives*")) GROUP BY [アカウントマスタ].Custmer_Number, [アカウントマスタ].Customer_Name, 詳細課金データ_With_ResourceID.[user:Name], 詳細課金データ_With_ResourceID.ProductName, UsageType.detail, UsageType.unit, 詳細課金データ_With_ResourceID.LinkedAccountId HAVING (((詳細課金データ_With_ResourceID.ProductName) Is Not Null) AND ((詳細課金データ_With_ResourceID.LinkedAccountId)=154946556956));
■各テーブル構成
TBL_アカウントマスタ
フィールド名 | データ型 | サイズ |
---|---|---|
AWS_Account | 12 | 数値型 |
Custmer_Number | 8 | 数値型 |
Customer_Name | 255 | テキスト型 |
ecplus | 1 | 数値型 |
TBL_Usagetype
フィールド名 | データ型 | サイズ |
---|---|---|
ID | - | オートナンバー型 |
key | 255 | テキスト型 |
detail | 255 | テキスト型 |
region_name | 255 | テキスト型 |
unit | 255 | テキスト型 |
active_flg | 1 | 数値型 |
TBL_詳細課金データ_With_ResourceID
フィールド名 | データ型 | サイズ |
---|---|---|
ID | - | オートナンバー型 |
InvoiceID | 255 | テキスト型 |
PayerAccountId | 12 | テキスト型 |
LinkedAccountId | 12 | テキスト型 |
RecordType | 255 | テキスト型 |
RecordId | 255 | 数値型 |
ProductName | 255 | テキスト型 |
RateId | - | テキスト型 |
SubscriptionId | - | テキスト型 |
PricingPlanId | - | テキスト型 |
UsageType | 255 | テキスト型 |
Operation | 255 | 数値型 |
AvailabilityZone | 255 | テキスト型 |
ReservedInstance | 255 | テキスト型 |
ItemDescription | 255 | テキスト型 |
UsageStartDate | yyyy/mm/dd | 日付/時刻型 |
UsageEndDate | yyyy/mm/dd | 日付/時刻型 |
UsageQuantity | - | 数値型 |
BlendedRate | - | 数値型 |
BlendedCost | - | 数値型 |
UnBlendedRate | - | 数値型 |
UnBlendedCost | - | 数値型 |
ResourceId | 255 | テキスト型 |
user:Name | 255 | テキスト型 |
user:Project | 255 | テキスト型 |
user:Solution | 255 | テキスト型 |
お手数ですが、よろしくお願い致します。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。