sqlplus compute sum subtotal
Date: Wed, 14 Apr 2010 15:54:08 -0600
Message-ID: <k2v47a6f72b1004141454pa32d2931vb7341a85fd23fffd_at_mail.gmail.com>
Oracle 9.2.0.7 on linux
I thought this should be simple (and perhaps, indeed, it is), but I’m not getting it.
I want a sum of the invoice amount when the category changes.
e.g., I don’t want the individual account details;
I just want a total for LEGAL, a total for RENTALS, etc.
Any help??
thanks! Barb
break on report on cg_category_group_name
compute sum label "Sub-Total" of invoice_amt on cg_category_group_name
compute sum of invoice_amt grand_total on report
SELECT ccd.cg_category_group_name,
f.acct_key, f.invoice_amt
FROM workorder_fact f, class_category_dim ccd
WHERE ccd.CC_CLASS_CAT_SID=f.CLASS_CAT_SID
group by
ccd.cg_category_group_name, f.acct_key,f.invoice_amt
CG_CATEGORY_GROUP_NAME ACCT_KEY INVOICE_AMT
- ---------- -----------
LEGAL 93815400 16.6 96966321 120 97354224 186 97354224 202 99486321 82
. . . . . . . .
- -----------
Sub-Total 104976.06 RENTALS 13790000 21.52 18970000 29 18970000 50.12 40180000 22 40180000 17.6
. . . . . . . .
- ----------- Sub-Total
Barb Baker
Denver Newspaper Agency
303-954-5384
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Apr 14 2010 - 16:54:08 CDT