Skip to content

平成22年度 秋期 ITパスポート試験 問84

This question's explanation and your answers so far.

問84
頻出度★★☆

関係データベースで管理している“商品”表及び“売上”表を結合して商品の売上集計を行う。5月の売上合計金額が最も大きい商品はどれか。 商品

商品コード商品名価格
0001商品A2,000
0002商品B4,000
0003商品C7,000
0004商品D10,000

売上

売上番号商品コード数量売上日配達日
Z00001000424/305/2
Z00002000115/15/3
Z00003000325/155/17
Z00004000135/155/18
Z00005000235/55/18
Z00006000125/105/20
Z00007000215/306/2
Z00008000126/16/9
Z00009000316/86/10
出典 平成22年度 秋期 ITパスポート試験 問84
解説

問 84

  • Incorrectア

    Product A has the most sales records in May, three of them, but its price is the lowest at 2,000 yen, so its total stops at 2,000×6 units=12,000 yen and does not reach Product B's 16,000 yen. A large number of sales records or a large quantity is a different thing from a large total amount; you must always convert to an amount with price × quantity before comparing.

  • イ

    正解 The correct answer is イ (Product B). First, join the “Sales” table to the “Product” table using the product code as the key; the amount of each sales row can then be found as price × quantity. Next, what the question asks about is “sales in May”, so take only the rows whose sales date falls in May (note that it is not the delivery date). Totaling by product: Product A has 1 unit in Z00002, 2 units in Z00006 and 3 units in Z00004, for 6 units in all, so 2,000×6=12,000 yen. Product B has 3 units in Z00005 (5/5) and 1 unit in Z00007 (5/30), for 4 units in all, so 4,000×4=16,000 yen. Product C has only the 2 units in Z00003 (5/15), so 7,000×2=14,000 yen. Product D has no sales rows in May, so 0 yen. Therefore the largest total amount is Product B with 16,000 yen.

  • Incorrectウ

    Product C's sales in May are only the 2 units of Z00003 (sales date 5/15), that is 7,000×2=14,000 yen, which is smaller than Product B's 16,000 yen. The other record, Z00009, has a sales date of 6/8, so it is a June sale and must not be included in the May aggregation.

  • Incorrectエ

    Product D has the highest price at 10,000 yen, but the sales date of the corresponding record Z00001 is 4/30, which makes it an April sale, so its May total is 0 yen. It is a mistake to be pulled along by the delivery date of 5/2 and count 10,000×2=20,000 yen. The date that decides what is aggregated is the date of the “sale” specified by the question, namely the sales date.

ここがポイント
  • The basic procedure for a join and aggregation: join the sales table to the product table on the product code to look up the price, compute the amount of each row as price × quantity, and total by product code. Being merely expensive per unit, or merely having many records, does not necessarily make the total amount the largest.
  • Do not mistake which column the extraction condition (selection) uses: when a table has several date columns such as sales date and delivery date, the “sales in May” that the question speaks of must be narrowed down by the sales date. Narrowing down by the delivery date would make Product D the largest at 20,000 yen and change the answer, so which column you specify the condition on decides the result.
用語

Your answers