lg4280 lg4280
关注数: 120 粉丝数: 14 发帖数: 136 关注贴吧数: 9
正在期末考试 ,这个什么不会呀,那位哥哥帮做下。看看题目先,。 11.     Write a query to produce the number of invoices and the total purchase amounts by customer, using the output shown in Figure P7.25 as your guide. (Compare this summary to the results shown in Problem 24.) FIGURE P7.25 Number of Invoices and Total Purchase Amounts by Customer Note that a query may be used as the data source for another query. The following code is shown in qryP7.25A in your Ch07_Saleco database. Note that the data source is qryP6-24. SELECT         CUS_CODE,              Count(INV_NUMBER) AS [Number of Invoices],              AVG([Invoice Total]) AS [Average Invoice Amount],              MAX([Invoice Total]) AS [Max   Invoice Amount],              MIN([Invoice Total]) AS [Min   Invoice Amount],              Sum([Invoice Total]) AS [Total Customer Purchases] FROM         [qryP7-24] GROUP BY     [qryP7-24].CUS_CODE; Instead of using another query as your data source, you can also use an alias. The following code is shown in Oracle format. You can also find the MS Access “alias” version in qryP7.25B in your Ch07_SaleCo database.) SELECT     CUS_CODE,      COUNT(LINE.INV_NUMBER) AS [Number of Invoices],      AVG([Invoice Total]) AS [Average Invoice Amount],      MAX([Invoice Total]) AS [Max   Invoice Amount],      MIN([Invoice Total]) AS [Min   Invoice Amount],      Sum([Invoice Total]) AS [Total Customer Purchases] FROM         (SELECT     CUS_CODE, LINE.INV_NUMBER AS INV_NUMBER, Sum(LINE.LINE_UNITS*LINE.LINE_PRICE) AS [Invoice Total]          FROM         INVOICE, LINE          WHERE     INVOICE.INV_NUMBER = LINE.INV_NUMBER          GROUP BY     CUS_CODE, LINE.INV_NUMBER) GROUP BY     CUS_CODE; 12.     Using the query results in Problem 25 as your basis, write a query to generate the total number of invoices, the invoice total for all of the invoices, the smallest invoice amount, the largest invoice amount, and the average of all of the invoices. (Hint: Check the figure output in Problem 25.) Your output must match Figure P7.26. FIGURE P7.26 Number of Invoices, Invoice Totals, Minimum, Maximum, and Average Sales SELECT     Count([qryP7-24].[INV_NUMBER]) AS [Total Invoices],          Sum([qryP7-24].[Invoice Total]) AS [Total Sales],          Min([qryP7-24].[Invoice Total]) AS [Minimum Sale],          Max([qryP7-24].[Invoice Total]) AS [Largest Sale],          Avg([qryP7-24].[Invoice Total]) AS [Average Sale] FROM     [qryP7-24];
1 下一页