Decode function... total at the end

Hi,
I am using following query to show results...
Select
ACCOUNT_CONSULTANT,
max((DECODE (SALES_STAGE, 'MEETING', Opportunities, NULL)
)) MEETING,
max((DECODE (SALES_STAGE, 'CLOSED', Opportunities, NULL)
)) CLOSED,
max((DECODE (SALES_STAGE, '', Opportunities, NULL)
)) TBD
From
select
ACCOUNT_CONSULTANT,
SALES_STAGE,
count(PROSPECT_NAME) as Opportunities
from Table_A
group by
ACCOUNT_CONSULTANT,
SALES_STAGE
group by
ACCOUNT_CONSULTANT
order by
ACCOUNT_CONSULTANT
results appear as follows
Acct_Conslt Meeting Closed TBD
Sales RepA 6 1 11
what I want is the total at the end, something like this
Acct_Conslt Meeting Closed TBD Total
Sales RepA 6 1 11 18
Please advice

Hi,
Assuming your present query is getting the right results, you can make it a sub-query. Just copy the whole query (except the ORDER BY clause) into a WITH clause or an in-line view. Then, in the main query, you can reference the computed columns meeting, closed and tbd, like this:
WITH     got_aggregates     AS
     Select
     ACCOUNT_CONSULTANT,
     max((DECODE (SALES_STAGE, 'MEETING', Opportunities, NULL)
     )) MEETING,
     max((DECODE (SALES_STAGE, 'CLOSED', Opportunities, NULL)
     )) CLOSED,
     max((DECODE (SALES_STAGE, '', Opportunities, NULL)
     )) TBD
     From
     select
     ACCOUNT_CONSULTANT,
     SALES_STAGE,
     count(PROSPECT_NAME) as Opportunities
     from Table_A
     group by
     ACCOUNT_CONSULTANT,
     SALES_STAGE
     group by
     ACCOUNT_CONSULTANT
SELECT       a.*
,       meeting + closed + tbd          AS total
FROM       got_aggregates   a
ORDER BY  account_consultant
;If the components of total can be NULL, then you'd better compute total like this:
,       NVL (meeting, 0) +
       NVL (closed,     0) +
       NVL (tbd,     0)          AS totalEdited by: Frank Kulash on Jun 3, 2010 5:39 PM
Fixed typo.

Similar Messages

  • How to add totaling at the end of BI Publisher Report. ????

    Dear All:
    I have payment amount in BI publisher . And I want its totaling at the end of each group. How can I add. Can any body know. Thanks
    ALi

    Hi,
    Think there are lots of posts on Tim's blog on totals, e.g.:
    http://blogs.oracle.com/xmlpublisher/2007/03/30#a221
    Regards,
    Gareth
    Blog: http://garethroberts.blogspot.com/

  • How to add a total at the end of a characteristic column

    Hi All,
    There is a report where sales document number(0doc_number)is displayed in one of the columns,
    now There is a requirement where I need to add a total count of those doc numbers at the end of that column.
    I am not able to find a suitable way to do that.
    I tried exception aggregation for taking a count of doc numbers but that will be another column then while I need the total at the end of the same
    column which already exists.
    Please assist.
    Thanks,
    Dolly

    Hi Suman,
    A part of the report is :
    I need a count as 2 in above example at the bottom of sales document column.
    Dolly

  • How to display the total at the end of the column in the report.

    Hi all,
    Could any one please intimate, how to display the total at the end of the column. For example, i have a column, "sales" as the Key figure, and it has the data for all the transactions. Now, i would like to display the total at the end of the report, below the same column.
    Similarly, for all the other columns in the report, i need to display the total for all the columns in the report.
    Thanks & Regards,
    A.V.N.Rao

    Hi All,
    Thanks for many suggestions. I tried by providing the "Total" under "Calculate Results as" and also "Counter for all detailed values" under "Calcuate Single Values as", in the  "Calculations" tab of the key figure, but i am unable to get the information. Again, i am providing the requirement below:
    CHAR - A   CHAR - B   TIME CH. - 1 KF -1  KF- 2 KF - 3
    1                     RAM        2012           1         50      50
    2                     SAM         2012          2         100    200
    Result                                               3           150   250
    Assume KF -1 as  "Qty." KF-2  as "Price" KF-3 as "Sales".
    Please intimate the solution.
    Thanks & Regards,
    A.V.N.Rao.

  • Printing totals at the end of the main window?

    Hi All,
    This is Hr related and the data displayed in the main window is regarding the five benefit plans. I need to add the values from each plan. But the number of plans displayed is not constant. The plans for which he is eligible are displayed. So I need to display the totals after completion of the data.
    I want to print totals in the main window at the end of the form.  The print program is a standard SAP program and it is not to be changed. I had calculated the totals by calling a perform in the script editor. Thats working fine.
    But the problem is while displaying it. Is there a solution to print totals at the end of the form without changing the print program or without creating a new element(as it cannot be called from the print program)?
    Thanks
    Satish

    See there are so many element which ends with the ATLAST, like INVEST_AT_LAST.
    You need to find out which AT_LAST is triggering in your prorgram. Or, you can use the AT_LAST element of the same family where you put your PERFORM to get the total.
    Say if you put your code at BENEFI_AT_EACH_PERSON, you can use the BENEFI_AT_LAST for displaying the TOTAL.
    Hope it helps..!
    Regards,
    Naimesh Patel

  • Problem with decode function while dispaly the data ( urgent )

    Hi friends ,
    I want the output like this.
    sample:
    CLIENT CODE: 00027
    PLAN CODE: 01
    SSN Last Name First Name TYPE Frequency Amount
    123-45-6036 Perrault Julia D M 250.00
    123-45-6036 Perrault Julia D Q 400.00
    CLIENT CODE: 00027
    PLAN CODE: 02
    SSN Last Name First Name TYPE Frequency Amount
    123-45-6036 Perrault Julia D S 1000.00
    123-45-7042 Testaverde Alexander D B 50.00
    this is my query:
    SELECT distinct pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name,
    pln.clt_client_id,
    DECODE(rp.account_code,'AMNT',rp.userid,NULL) amount,
    DECODE(rp.account_code,'FREQ',rp.userid,NULL) frequence,
    DECODE(rp.account_code,'TYPE',rp.userid,NULL) type
    FROM rp_extract_recon rp,
    plan pln,
    indicative ind
    where ind.indicative_id in ( select distinct
    rp1.ind_indicative_id
    from rp_extract_recon rp1
    where rp1.rp_extract_recon_id =
    rp.rp_extract_recon_id )
    and ind.clt_client_id = pln.clt_client_id
    and pln.plan_id = rp.pln_plan_id
    and rp.bat_batch_info_id = 14078
    and rp.rp_report_type_code = 'TEST'
    output for above query:
    PLAN_C SSN LAST_NAME FIRST_NAME CLT_C AMOUNT
    FREQUENCE TYPE
    01 123456036 Perrault Julia 00027 250.00
    01 123456036 Perrault Julia 00027 400.00
    01 123456036 Perrault Julia 00027 M
    01 123456036 Perrault Julia 00027 Q
    01 123456036 Perrault Julia
    00027 D
    02 123456036 Perrault Julia 00027 1000.00
    02 123456036 Perrault Julia 00027 S
    02 123456036 Perrault Julia
    00027 D
    02 123457042 Testaverde Alexander 00027 50.00
    02 123457042 Testaverde Alexander 00027 B
    02 123457042 Testaverde Alexander
    00027 D
    11 rows selected.
    11 rows selected.
    how can i get the above ouput .
    i want the type,frequency,amount values in one line.
    thanks for u r kind help
    srini

    Hi Srini,
    Add Max in the begining and group by at the end of statement.
    Please let me know in both cases if it works or not.
    thanks
    for example
    SELECT distinct pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name,
    pln.clt_client_id,
    MAX(DECODE(rp.account_code,'AMNT',rp.userid,NULL) amount,
    DECODE(rp.account_code,'FREQ',rp.userid,NULL) frequence,
    DECODE(rp.account_code,'TYPE',rp.userid,NULL) type )
    FROM rp_extract_recon rp,
    plan pln,
    indicative ind
    where ind.indicative_id in ( select distinct
    rp1.ind_indicative_id
    from rp_extract_recon rp1
    where rp1.rp_extract_recon_id =
    rp.rp_extract_recon_id )
    and ind.clt_client_id = pln.clt_client_id
    and pln.plan_id = rp.pln_plan_id
    and rp.bat_batch_info_id = 14078
    and rp.rp_report_type_code = 'TEST'
    GROUP BY
    pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name,
    pln.clt_client_id,

  • I need to display separate bar for totals at the end of the barchart.

    Hi All,
    My scenario is similar to the one described below
    http://siebel.ittoolbox.com/groups/technical-functional/siebel-analytics-l/displaying-grand-total-column-as-a-seperate-vertical-bar-in-a-bar-chart-report-3351958
    I didn't understand how the combined request solved this problem but I tried my self creating a pivot table chart with new calculated column as 'Total'. The problem is I am getting value '0' on the X-axis of the pivot table bar chart instead of Total but values shows up correct. Can Someone let me know where I was doing wrong?
    Thanks

    Hi Sam and Sankat,
    My requirement is to show values of each month along with Total value in the same bar chart. Month would be on X-axis. and on Y axis is the value. The problem with union report is,it would show total value along with each value for each month. I dont want that. I want just a separate single bar for each month for the corresponding value and at the last i want a separate bar which totals the entire value.
    With the pivot view chat. I created a new calculated item and named it as Total and sum the values of all column. It shows the right value and I am getting the graph correctly like I wanted but instead of 'Total' label, i am getting the label as 'o'. this is not defined by me or a column in the dimension
    Thank you,
    Kavya

  • Totally at the end of my tether with bill and pric...

    New to this but totally at my wits end over it. I rang BT end of Dec and asked to be put on the anytime price plan as they were going to charge me £32 a month from £24.50 a month as I was making daytime calls.
    I simply asked if I could clear my account and then be put on an anytime plan from Jan. I was told I owed £7.75, queried this but they insisted it was correct. I wrote a cheque for £7.75. Got letters after sayin I would be paying £17.50 anytime plan which was a £2 reduction for being with BT for a while. Then got a letter they would take £20 a month from me. I rang and then got told it would be £17.50 as we had agreed. They had received my cheque.
    Now my latest bill says I am £50.45 in debit and from April will be charged £31.50 a month. yet other parts of the bill says I will be paying £19.50 from Feb to May with a £2 reduction.
    I need a degree to understand the bill. Numerous phone calls and I still cannot understand it all HELP, its taking over my life trying to sort it. How fantastic it would be if you could help me.

    You're right - the bills can be terribly difficult to fathom. 
    First things first, the £17.50 basic charge is correct (line rental £14.60 + Anytime calls £4.90 - £2 discount).  But your monthly payment ought to be a bit more to cover chargeable calls, unless you're absolutely sure not to make any.
    Your bill should be in 4 sections:
    1. Your starting credit, hopefully a minus figure. This is the payments you have made since the previous bill, adjusted by any credit or debit brought forward.
    2. Your basic charges. This is in advance and should be 3 x £17.50 = £52.50, but there may be items brought forward.
    3. Additional charges. Obviously, this is what you used above your basic charges.
    4. The bottom line.
    If you paid £17.50 a month and there were no other factors, your bill would show payments of £52.50 in section 1, charges of £52.50 in section 2, and zero in sections 3 & 4.
    But, as you rightly surmised, to get a bill like that you would need to start with a zero balance, and that clearly has not happened. I'm guessing that the £50.45 debt is the bottom line on your latest bill, in which case it will not relate to advance charges as suggested by oldie68. It is a debit; if it is correct your future monthly payments would have to cover it, and an extra £14 a month against a debit of £50 is not unreasonable.
    If you can post details of your latest bill (with any personal information deleted) we could try to unpick it for you to see if it is correct.
    You can click the white star next to this message if you think it was helpful.

  • How to get page totals at the end of the report in BI Publisher

    I am using BI Publisher 10.3 and using Ms-Word template builder to design the report
    and I want to implement totals for some columns (like page totals) ... can anyone let me know how to go about this
    Thanks

    Take a look this blog: http://blogs.oracle.com/xmlpublisher/entry/anatomy_of_a_template_iii_page
    You can download the template for that page.
    Also take a look at the Samples folder within your BI publisher desktop folder and you can find a folder "Page Total" that has the RTF template, xml and output..
    Assign points if helpful.
    Thanks,
    Bipuser
    Edited by: BIPuser on Aug 18, 2011 8:24 AM

  • Problem with decode function while dispaly the data

    Hi friends ,
    I want the output like this.
    sample:
    CLIENT CODE: 00027
    PLAN CODE: 01
    SSN Last Name First Name TYPE Frequency Amount
    123-45-6036 Perrault Julia D M 250.00
    123-45-6036 Perrault Julia D Q 400.00
    CLIENT CODE: 00027
    PLAN CODE: 02
    SSN Last Name First Name TYPE Frequency Amount
    123-45-6036 Perrault Julia D S 1000.00
    123-45-7042 Testaverde Alexander D B 50.00
    this is my query:
    SELECT distinct pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name,
    pln.clt_client_id,
    DECODE(rp.account_code,'AMNT',rp.userid,NULL) amount,
    DECODE(rp.account_code,'FREQ',rp.userid,NULL) frequence,
    DECODE(rp.account_code,'TYPE',rp.userid,NULL) type
    FROM rp_extract_recon rp,
    plan pln,
    indicative ind
    where ind.indicative_id in ( select distinct
    rp1.ind_indicative_id
    from rp_extract_recon rp1
    where rp1.rp_extract_recon_id =
    rp.rp_extract_recon_id )
    and ind.clt_client_id = pln.clt_client_id
    and pln.plan_id = rp.pln_plan_id
    and rp.bat_batch_info_id = 14078
    and rp.rp_report_type_code = 'TEST'
    output for above query:
    PLAN_C SSN LAST_NAME FIRST_NAME CLT_C AMOUNT
    FREQUENCE TYPE
    01 123456036 Perrault Julia 00027 250.00
    01 123456036 Perrault Julia 00027 400.00
    01 123456036 Perrault Julia 00027 M
    01 123456036 Perrault Julia 00027 Q
    01 123456036 Perrault Julia
    00027 D
    02 123456036 Perrault Julia 00027 1000.00
    02 123456036 Perrault Julia 00027 S
    02 123456036 Perrault Julia
    00027 D
    02 123457042 Testaverde Alexander 00027 50.00
    02 123457042 Testaverde Alexander 00027 B
    02 123457042 Testaverde Alexander
    00027 D
    11 rows selected.
    11 rows selected.
    how can i get the above ouput .
    i want the type,frequency,amount values in one line.
    please help me.
    thanks for u r kind help.
    srini

    Hi.
    I have not tested this my self, byt tryit.
    SELECT pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name,
    pln.clt_client_id,
    MAX(DECODE(rp.account_code,'AMNT',rp.userid,NULL)) amount,
    MAX(DECODE(rp.account_code,'FREQ',rp.userid,NULL)) frequence,
    MAX(DECODE(rp.account_code,'TYPE',rp.userid,NULL)) type
    FROM rp_extract_recon rp,
    plan pln,
    indicative ind
    where ind.indicative_id in ( select distinct
    rp1.ind_indicative_id
    from rp_extract_recon rp1
    where rp1.rp_extract_recon_id =
    rp.rp_extract_recon_id )
    and ind.clt_client_id = pln.clt_client_id
    and pln.plan_id = rp.pln_plan_id
    and rp.bat_batch_info_id = 14078
    and rp.rp_report_type_code = 'TEST'
    GROUP BY pln.plan_code,
    ind.ssn,
    ind.last_name,
    ind.first_name
    /Uffe

  • I keep track of family totals for fundraising at a school, I want a family name and totals for each fundraiser and then at the end of the year I would like an alphabetized list.  Can I do this in numbers?

    in numbers, how would I make a line for each family (100+)  a column for each fundraiser. and at mid year, and year end be able to print an alphabetical listing?
    example:     entertainment books          Chip Shoppe       Yankee Candle
    Smith          $350                                   $245                    $100
    Total at the end of the line, but I could live without.  I am just trying to lose the paperwork, and have it in the ipad for when parents approach me at meetings.
    Help!

    HI m,
    Using Numbers '09 (the Mac version), I'd use a table with one header row and two header columns.
    Family     Total     Ent.Books     Chip S.     Y. Candle
    Smith, J      $695        350            245             100
    Jones, T      $765        250            445               70
    An ascending sort on column A will put the families in alphabetical order (and carry the rest of the row along with them).
    The formula =SUM(2) in B2, and filled down from there, keeps the total for each family right beside the family name.
    You could add a Footer row at the bottom to keep totals for each column. Formula for column B: =SUM(B)
    I would leave the currency signs ($) off the amounts—they just clutter up the table.
    This assumes that the features listed are all supported on Numbers for iOS, the version running on your iPad.
    Regards,
    Barry

  • Converting Decode function in OBIEE

    Hi Guru's
    we are converting some BO reports to OBIEE and need to convert Decode function
    Below is the Decode function they are using:
    Decode ( sign(nvl(BOOKINGS_DATA_UDTC.qty_shipped,0)), 0,decode(BOOKINGS_DATA_UDTC.DELIVERY_NUMBER, 0,decode(BOOKINGS_DATA_UDTC.Schd_Ship_date_fk,to_date('1/1/1990','mm/dd/yyyy'),'Next Month Backlog',decode(sign(nvl(BOOKINGS_DATA_UDTC.Schd_Ship_date_fk, '01-JAN-90') -PAR.PAR_DATE), 1, 'Next Month Backlog', 'Current month will ship')) ,'Awaiting for collection') ,'MTD Shipped')
    i have tried converting into case :
    case when sign(IFNULL("BOOKINGS_DATA_UDTC"."Qty Shipped",0)) = 0 then (case when "BOOKINGS_DATA_UDTC"."Delivery Number" = 0 then (case when "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" = '01-JAN-1990' then 'Next Month Backlog' else (case when Timestampdiff(SQL_TSI_DAY, cast('@{ParDate}{28-DEC-2012}' as Date),(case when "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" IS NULL then CAst('01-JAN-1990' as DATE) else "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" end)) > 1 then 'Next Month Backlog' else 'Current Month Will Ship' end) end) else 'Awaiting For Collection' end) else 'MTD Shipped' end
    But it is not workign as expected.
    Can some one please help me with this.
    Thanks,

    you can achieve it by using CASE WHEN condition END function in obiee. nested case also supported by obiee.
    check the below link Decode Join  Condition in OBIEE RPD
    Thanks
    Jay.
    Edited by: Jay on Apr 3, 2012 12:56 PM

  • Issue in calculating sum on a column at the end of the report in Pivot view

    Hi,
    I have some columns like Hierarchy column A, Non Hierarchical columns B, C and a measure D.
    In Pivot view under rows I have placed columns A,B and C in Columns and D in measures. If I try to calculate sum of values at the end of report by using option Sum At the End on columns we are getting an error that grouping by function should be in the select clause of the query.
    If I duplicate the column C and put it in rows then I am able to see totals at the end but values are displayed in multiple rows and it won't meet our requirement.
    Any suggestion or workarounds on this will be helpful.
    Thanks,
    Vj

    Hi,
    let me explain it better..
    Col A: GL Segment Hierarchy which will display Level1 to Level n Names
    Col B: Level n Code.
    Col C: Fiscal Period
    Col D: Amount
    Now col A and B are in Rows, col c in columns and col D in measures in a pivot view.
    Issue is we are unable to have total of measure values at the end of report by using sum at the end.

  • Display totals on the first line in ALV grid and ALV LIST

    Generally we wll display totals at the end..
    bu the requirement is to display it in the first line of the column.
    how to display the totals in the first line?
    I have used ALV GRID and ALV LIST (choice) using function modules.
    Plz help me
    .for example : Po qty : Should display total po qty on the first line of the Po line item.

    IN LAYOUT
    ILAYOUT-totals_before_items = 'X'.
    REGARDS
    SHIBA DUTTA

  • Decode Function issue

    Hi all,
    i want compare two rows in a table. so i used decode function to compare the values, whether its matched or not.
    One of my table column has Long data type.
    Decode(a.col1,b.col1,'Match','NotMatch')
    col1 - is long data type.
    when i use long data type, i got below error,
    is there anyway to rectify this error.
    SQL Error: ORA-00932: inconsistent datatypes: expected NUMBER got LONG
    00932. 00000 - "inconsistent datatypes: expected %s got %s"
    Thanks in advance.
    Regards,
    Santhosh

    >
    You can't use ANY function on a LONG column. This restriction is not limited to DECODE.
    >
    Not quite correct.
    You can use TO_LOB on a LONG column but only in the select list of a subquery in an INSERT statement.
    See TO_LOB in the SQL Language doc
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions205.htm#SQLRF06134
    >
    TO_LOB converts LONG or LONG RAW values in the column long_column to LOB values. You can apply this function only to a LONG or LONG RAW column, and only in the select list of a subquery in an INSERT statement.
    Before using this function, you must create a LOB column to receive the converted LONG values. To convert LONG values, create a CLOB column. To convert LONG RAW values, create a BLOB column.
    You cannot use the TO_LOB function to convert a LONG column to a LOB column in the subquery of a CREATE TABLE ... AS SELECT statement if you are creating an index-organized table. Instead, create the index-organized table without the LONG column, and then use the TO_LOB function in an INSERT ... AS SELECT statement.
    You cannot use this function within a PL/SQL package. Instead use the TO_CLOB or TO_BLOB functions.

Maybe you are looking for

  • The file .docx cannot be opened because there are problems with the contents in sharepoint document library

    I created a site and  created a document libarary and assigned a word document as a content type . I have written a workflow to create a new document . The workflow is working fine and all the document is getting created and values are getting stored

  • Update 8.0.2 problems

    Since updating my iPad 2 to the iOS 8.0.2 I have lost connectivity to my cellular network as well as the battery life dying quickly. Another odd thing is all my music shows up but when I go to play it nothing is downloaded and I'm not able to play? 

  • Automatically delete email?

    Is there a way to automatically delete mail from all users after, say 90 days? I apologize if this sounds like a simple/stupid question. thanks in advance. Olifer

  • Express works for 2 laptops but not imac

    Hi - I have Airport Express connected to Motorola cable modem. I have two macbooks both connecting to internet via Airport Express fine. But my iMac doesn't. iMac reports that AirPort is connected to xxx Network and has IP address 10.0.1.3 - the two

  • Sorting Contacts by company

    Is there a way to view contacts by company.  What I am trying to do is group multiple contacts by their company.  I have chosen to view by "company, last name" but I would like to be able to search the company name to find the contact I seek. Thanks