することにより、グループを使用して総計を取得します。私は、行ごとに各グループの合計、数、平均を得ることができました。は、私は現時点では自分自身SQLについての詳細を教えしようとしていますし、現在のSQL Server 2008データベース内<code>SUM</code>、<code>COUNT</code>、<code>AVG</code>と<code>GROUP BY</code>機能を使用して報告するいくつかの簡単な販売を実施しようとしています
すべてのグループの合計を行単位で取得するにはどうすればよいですか?これまで
SQL:
SELECT
SUM(dbo.tbl_orderitems.mon_orditems_pprice) AS prodTotal,
AVG(dbo.tbl_orderitems.mon_orditems_pprice) AS avgPrice,
count(dbo.tbl_orderitems.uid_orditems_prodid) AS prodQty,
dbo.tbl_orderitems.txt_orditems_pname
FROM
dbo.tbl_orderitems
INNER JOIN
dbo.tbl_orders
ON (dbo.tbl_orderitems.uid_orditems_orderid = dbo.tbl_orders.uid_orders)
WHERE
dbo.tbl_orders.uid_order_webid =
<cfqueryparam cfsqltype="cf_sql_integer" value="#session.webid#">
AND dbo.tbl_orders.txt_order_status =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.sale_status#">
GROUP BY
dbo.tbl_orderitems.txt_orditems_pname
Product Qty Gross Avg Westbury Climbing Frame 17 8,023.00 471.94 Sandpoint Deluxe Climbing Frame 34 36,146.00 1,063.12 Roseberry Climbing Frame 9 7,441.00 826.78 Ridgeview Texas Climbing Frame 10 6,990.00 699 Selwood Picnic Table 9 489.92 54.44 I need the Totals of qty column and gross column
感謝
ジェイソン
出力の例を挙げることはできますか? – Lock
['GROUPING SETS'](http://technet.microsoft.com/en-us/library/bb510427(v=sql.100).aspx) –
を参照してください。申し訳ありません! –