I used with rollup to add a Grand Total in the result.

BEGIN select a.InvoiceNumber ,a.InvoiceDate,dbo.GetCompanyName(CompanyId) Company,isnull(convert(VARCHAR,a.InvoiceNumber),'GRAND TOTAL') AS InvoiceNumber, sum((Sum(isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0))) AS 'Total In Inventory',(Select ProjectCode from tblProjectmmc where id=ProjectId)as ProjectId,a.BusinessUnit,(Sum(isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0)) as InvoiceAmount, a.UserId as ProjectManager from tblinvoicemmc a inner join tblInvoiceItemDescriptionmmc b on a.InvoiceNumber=b.InvoiceNumber group by a.invoicenumber,a.GST,a.InvoiceDate,a.CompanyId,a.ProjectId,a.UserId,a.BusinessUnit with rollup ORDER BY a.Invoicenumber DESC ; End
but giving error
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
Sms

BEGIN
select a.InvoiceNumber ,a.InvoiceDate,dbo.GetCompanyName(CompanyId) Company,isnull(convert(VARCHAR,a.InvoiceNumber),
'GRAND TOTAL') AS InvoiceNumber, sum((isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0)) AS 'Total In Inventory',
p.ProjectCode as ProjectId,
a.BusinessUnit,(Sum(isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0)) as InvoiceAmount,
a.UserId as ProjectManager
from tblinvoicemmc a
inner join tblInvoiceItemDescriptionmmc b
on a.InvoiceNumber=b.InvoiceNumber
left join tblProjectmmc p
on p.id = a.ProjectId
group by a.invoicenumber,a.GST,a.InvoiceDate,a.CompanyId,p.ProjectCode,a.UserId,a.BusinessUnit
with rollup
ORDER BY a.Invoicenumber DESC ;
End
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to use TextField to add two numbers and show the result.

    hi everybody
    i would like to use JTextField to get addtion of two Numbers,
    for example i am trying to type any integer numbers in JTextField like 7
    and press JButton, called( +) to add anthor number like 7 and press JButton called(=) to get addtion fo
    7 + 7 = 14, at same JTextField.
    so there will be two buttons, one for (+),other for (=).
    i have implement ActionListener in (+) button ,to get Text from JTextField (with getText() method),
    now how do i use same getText() method to get the next number that i will add it with previous number in
    (+) button and get the result whenever i press (=).
    1-type integer number like (4) in TextField.
    2-press addition button(+) to get text by using getText() method and clear TextField.
    3-type anthor integer number like(6).
    4-press (=) button to get the number (6) by using getText() method, calculate 4 + 6 and show the result at same TextField (10).
    i hope it is so clear
    thank u in advance for any advice and suggestion.

    Use your first button to
    String x = JTField.getText();
    int y = Integer.parseInt(x);
    this will get your first value on your + button. Make sure you initialise the int beforehand incase nothing is put in (ie error prevention) then clear the JTField prob using setText(""). Repeat the process for the = button using different variables and add them normally and output the result.
    If your putting more than 1 arithmetic button on the GUI then you'll need to distinguish between them!!!

  • Is there an app you can use with iphoto to add ghosts to pictures

    I am trying to find an app to use with iphoto to add "ghosts" to existing pictures.. does anyone know of any?

    photoshop?

  • Can I buy a new ipd that takes a sim card to use with my local carrier? They only sell the ipad 2.

    Can I buy a new iPad that uses a sim card to use with my local carrier? They only offer the iPad 2 for sale.

    A quick Google search shows Union Wireless is GSM.  Buy the AT&T version (GSM) iPad.  You don't have to purchase iPad 2.  You can purchase the newer iPad from Apple or Best Buy, or even Walmart.  In either case, you get a micro sim from Union Wireless, purchase a data plan and enjoy.........

  • How to add a dummy row in the result set of a SELECT statement.

    Hello Everyone -
    I have requirment to add a dummy row in the result set of a SELECT statement.
    For e.g. lets say there is a table Payment having following colums:
    Payment_id number
    status varchar2(10)
    amount number
    payment_date date
    so here is the data :-
    Payment_id Status Amount payment_date
    1 Applied 100 12/07/2008
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    Here is my SQL
    Select * form payment where payment_date >= 01/01/2009
    Output will be
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    My desired output is below
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    2 Reversed -200 01/ 06/2009 ------(Dummy Row)
    Thrid row here is the dummy row which I want to add when status is "Reversed"
    I would be very thankful for any kind of help in this regard ...
    Thanks,
    Gaurav

    Cartesion joining against a dummy table is a useful method of creating a dummy row:
    with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
                    --- end of mimicking your table
          dummy as (select 'Reversed' col1, 1 rn from dual union all
                    select 'Reversed' col1, 2 rn from dual)
    select mt.cust_id,
           mt.payment_id,
           mt.status,
           decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
           mt.payment_date
    from   my_tab mt,
           dummy
    where  mt.status = dummy.col1 (+)
    order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
    CUST_ID     PAYMENT_ID     STATUS     AMOUNT     PAYMENT_DATE
    1     1     Applied     100     07/12/2008
    1     2     Reversed     200     06/01/2009
    1     2     Reversed     -200     06/01/2009
    1     3     Applied     300     06/01/2009
    2     1     Applied     100     07/12/2008
    2     2     Reversed     200     05/01/2009
    2     2     Reversed     -200     05/01/2009
    2     3     Applied     300     06/01/2009
    2     4     Reversed     -400     06/01/2009
    2     4     Reversed     400     06/01/2009
    2     5     Applied     500     07/01/2009Edited by: Boneist on 07-Jan-2009 23:10
    NB. You may have to mess around with the ordering if that's not come back in the order you wanted. You didn't mention what the rules were for any expected ordering though, so I've made up my own *{;-)
    Also, I added an identifier (cust_id) to differentiate between different sets of payments, since that's usually the case. Remove that if it's not applicable for your case.

  • How to display subtotals in every page and the grand total in the last page

    Hello Abapers,
                         I am working with Smartforms. I am not able to print the subtotal in every page ie the Price for that particular page alone should be summed and in the final page I want the grand total also to be displayed. I tried the Total option in the Calculations tab but the value is just getting incremented on every page..How can I achieve this..
    With Regards,
    Bennet.

    Hi,
    Declare two different variables for subtotal and total
    Use them in the calculation tab of the table node.
    After displaying the subtotal create a program lines node to clear the value of the subtotal. And dont forget to mention the condition in the condition tab of the text node of your subtotal as only before end of main window.
    display the grand total in the text another text node with condition... only after end of main window.
    regards
    padma

  • Need to Achieve Grand Total in the Data Template

    Hi Team
    As per the requirements i need to achieve the grand total form the various level of Total. To achieve the Total i have used the SUM function and it works fine. Could you please suggest me how can i achieve the Grand Total. For your reference i am attaching the data template here that i am using.
    <group name="G_ITEM" dataType="varchar2" source="Q_ITEMQuery" groupFilter="">
                        <element name="ITEM_ID" dataType="varchar2" value="item_id" function=""/>
                        <element name="DESCRIPTION" dataType="varchar2" value="description" function=""/>
                        <element name="DIVISION" dataType="varchar2" value="division" function=""/>
                        <element name="UNITS_APPTD" dataType="varchar2" value="apptd_unit_qty" function=""/>
                        <element name="UNITS_RCVD" dataType="varchar2" value="unit_rcvd" function=""/>
                        <element name="WEIGHT_APPTD" dataType="varchar2" value="apptd_weight" function=""/>
                        <element name="WEIGHT_RCVD" dataType="varchar2" value="receipt_weight" function=""/>
                        <element name="SUM_UNITS_APPTD" value="G_ITEM.UNITS_APPTD" function="SUM()"/>
                        <element name="SUM_UNITS_RCVD" value="G_ITEM.UNITS_RCVD" function="SUM()"/>
                        <element name="SUM_WEIGHT_APPTD" value="G_ITEM.WEIGHT_APPTD" function="SUM()"/>
                        <element name="SUM_WEIGHT_RCVD" value="G_ITEM.WEIGHT_RCVD" function="SUM()"/>
                        <group name="G_TROUBLE" dataType="varchar2" source="Q_TROUBLEQuery" groupFilter="">
                             <element name="T_CODE" dataType="varchar2" value="trouble_code" function=""/>
                        </group>
                   </group>
                   <group name="G_DEPOSIT" dataType="varchar2" source="Q_DEPOSITQuery" groupFilter="">
                        <element name="ITEM_ID1" dataType="varchar2" value="ITEM_ID1" function=""/>
                        <element name="DESCRIPTION1" dataType="varchar2" value="DESCRIPTION1" function=""/>
                        <element name="UNIT_QTY1" dataType="varchar2" value="Unit_Qty1" function=""/>
                        <element name="SUM_UNIT_QTY1" value="G_DEPOSIT.UNIT_QTY1" function="SUM()"/>
                   </group>
                   <group name="G_TRANSPORT" dataType="varchar2" source="Q_TRANSPORTQuery" groupFilter="">
                        <element name="ITEM_ID2" dataType="varchar2" value="ITEM_ID2" function=""/>
                        <element name="DESCRIPTION2" dataType="varchar2" value="DESCRIPTION2" function=""/>
                        <element name="UNIT_QTY2" dataType="varchar2" value="Unit_Qty2" function=""/>
                        <element name="SUM_UNIT_QTY2" value="G_TRANSPORT.UNIT_QTY2" function="SUM()"/>
                   </group>
    I need SUM_UNITS_APPTD, SUM_UNIT_QTY1 and SUM_UNIT_QTY2 of 3 different group to be added to generate the Grand Total. PLEASE ADVISE
    Regards
    Srikant

    Hi Domnic
    Thanks for the reply.
    I am not much aware of the XDO. Could you please let me know can i pass the field name in place of 2 and 3 as in your example.
    For example if i have field A and B and i need to add it then should it be
    <?xdofx:A+B?> in RTF.
    Else please give me the complete syntax.
    Thanks in advance for your reply.
    Regards
    Srikant

  • (Smartform) Print grand total on the last page

    Hi everyone,
    I'm trying to print the Grand Totals on the last page of my Smartform. I have two pages - FIRST and SECOND.
    What I did was I created a Text to display the grand total, and I specified that this text should be printed 'Only After End of Main Window'. However, the total is not being printed out.
    I can't change the condition to 'Not on First Page', because my form has more than two pages, and I only want the grand totals on the last page.
    Any help would be appreciated.

    hi,
    we have a window type called final window if u define this type window in second page . create a table in the window and go to calculations tab and define an internal table. i think u can get the grand totals.
    if u want maore clearly go throuh this link
    https://www.sdn.sap.com/irj/sdn/forums
    hope this will help you.
    REWARD ME IF USEFUL.
    thanks,
    gupta
    Edited by: gupta pullipudi on Apr 9, 2008 9:23 PM

  • Grand Total on the Header page

    Post Author: RogerR
    CA Forum: General
    Say I'm created a multiple page estimate report. As all the labor and material costs are being created and added up.
    Is it possible to put that Grand Total on the first page?
    Can you process the report first to get the numbers then print the report? I guess this is what would need to happen.

    Post Author: SKodidine
    CA Forum: General
    If you summarize a field (not a running total) then you should be able to create the summary field and move it to the Report Header without any problems.  This cannot be done if you use running totals for obvious reasons.

  • Adding a grand total to the columns

    Hi
    I need to add a total to one of the columns in my report. I have set Aggregation rule as "Sum" but it is not displaying Grand Total.
    Am I missing any thing or setting the rule incorrectly?
    Please advise.
    Thanks in Advance.
    Jas

    Hi Arvindh
    Thanks for your response. I am not using a pivot table I just tried to add total to the table which is created by just selecting columns required in the Define Criteria section.
    We can add a total w/o creating the pivot table also. By the way, I have found the solution. The key lies in the second step. If u want me to explain in detail. Just let me know.
    -Jas

  • Grand total showing wrong results

    Hello,
    I am having one prblem,using obiee 11g.
    Have a pivot table with 3 columns, one is month and other are showing numbers.
    For month we show the 2 number columns
    when i click grand total its showing the wrong total for the second number column.
    I really don't understand why its happening?
    Any help?
    Thanks

    Hi,
    Set Aggregation Rule as Server Complex Aggregate may solve your problem, ie goto
    Column -> Edit Formula -> Aggregation Rule -> Server Complex Aggregate
    Thanks,
    Balaa...

  • How to auto save output with date added to file name, and email the results?

    Hi,
    We found a script to capture disk space usage, that automatically places the results into an Excel file. We would like the script to autosave this file to a specific directroy with the date ran as part of teh file name. We would then like these results to
    be emailed to us if possible. (also if possible to highlight cell in red that is 5% OR less available disk space would be great)
    Here is what we have:
    $erroractionpreference = “SilentlyContinue”
    $a = New-Object -comobject Excel.Application
    $a.visible = $True
    $b = $a.Workbooks.Add()
    $c = $b.Worksheets.Item(1)
    $c.Cells.Item(1,1) = “Machine Name”
    $c.Cells.Item(1,2) = “Drive”
    $c.Cells.Item(1,3) = “Total size (GB)”
    $c.Cells.Item(1,4) = “Free Space (GB)”
    $c.Cells.Item(1,5) = “Free Space (%)”
    $c.cells.item(1,6) = "Name "
    $d = $c.UsedRange
    $d.Interior.ColorIndex = 19
    $d.Font.ColorIndex = 11
    $d.Font.Bold = $True
    $d.EntireColumn.AutoFit()
    $intRow = 2
    $colComputers = get-content "C:\Servers.txt"
    foreach ($strComputer in $colComputers)
    $colDisks = get-wmiobject Win32_LogicalDisk -computername $strComputer -Filter “DriveType = 3"
    foreach ($objdisk in $colDisks)
    $c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
    $c.Cells.Item($intRow, 2) = $objDisk.DeviceID
    $c.Cells.Item($intRow, 3) = “{0:N0}” -f ($objDisk.Size/1GB)
    $c.Cells.Item($intRow, 4) = “{0:N0}” -f ($objDisk.FreeSpace/1GB)
    $c.Cells.Item($intRow, 5) = “{0:P0}” -f ([double]$objDisk.FreeSpace/[double]$objDisk.Size)
    $c.cells.item($introw, 6) = $objdisk.volumename
    $intRow = $intRow + 1
    $d.EntireColumn.AutoFit()
    cls
    Thank You

    Hi Phorbin1128,
    The script below amy be helpful for you to save the Excel file with date in filename, and send email with the attachment of the excel report.
    $erroractionpreference = “SilentlyContinue”
    $a = New-Object -comobject Excel.Application
    $a.visible = $True
    $b = $a.Workbooks.Add()
    $c = $b.Worksheets.Item(1)
    $c.Cells.Item(1,1) = “Machine Name”
    $c.Cells.Item(1,2) = “Drive”
    $c.Cells.Item(1,3) = “Total size (GB)”
    $c.Cells.Item(1,4) = “Free Space (GB)”
    $c.Cells.Item(1,5) = “Free Space (%)”
    $c.cells.item(1,6) = "Name "
    $d = $c.UsedRange
    $d.Interior.ColorIndex = 19
    $d.Font.ColorIndex = 11
    $d.Font.Bold = $True
    $d.EntireColumn.AutoFit()
    $intRow = 2
    $colComputers = get-content "C:\Servers.txt"
    foreach ($strComputer in $colComputers)
    $colDisks = get-wmiobject Win32_LogicalDisk -computername $strComputer -Filter “DriveType = 3"
    foreach ($objdisk in $colDisks)
    $c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
    $c.Cells.Item($intRow, 2) = $objDisk.DeviceID
    $c.Cells.Item($intRow, 3) = “{0:N0}” -f ($objDisk.Size/1GB)
    $c.Cells.Item($intRow, 4) = “{0:N0}” -f ($objDisk.FreeSpace/1GB)
    $c.Cells.Item($intRow, 5) = “{0:P0}” -f ([double]$objDisk.FreeSpace/[double]$objDisk.Size)
    $c.cells.item($introw, 6) = $objdisk.volumename
    $intRow = $intRow + 1
    $d.EntireColumn.AutoFit()
    $date=Get-Date -f yyyy-MM-dd
    $filename = "D:\test\"+$date+".xlsx"
    $b.SaveAs($filename)
    $a.Quit()
    Send-MailMessage -SmtpServer xxxxxxxxxx -To [email protected] -From [email protected] -Subject "test mail" -Body "file name is: $new_file" -attachment $filename
    For more detailed information about the cmdlet Send-MailMessage, please refer to this article:
    Send-MailMessage
    I hope this helps.

  • Grand Total on the same line. See Output requirment.

    Env:Oracle 9I Report Writer
    If I have a Table with the flwg data:
    TableA
    Col1   Col2  Col3   Amt
    1                   10
    2                   20
    3                   30
    4                   40How can I get the report output in the format below:
    ....            Amt    Total
                    10
                    20
                    30
                    40     100Is this possible?

    Yes
    presumably your total is in a repeating frame above the detail. What you need to do is make your detail repeating frame shorter than the page width. Your total repating frame should extend to the page width. You an then insert your total on the same line as the detail.
    This will probably put the total at the top, rather than the bottom. I think you can get around this by using anchors

  • Get Grand total of the subtotals

    Hi,
    I am devoloping a report which pulls the expense lines for each project.I am displaying the fte count at each line.As it'll be same for a particular project,all the lines for that particular project will show the same FTE count.I am grouping the
    lines by Project No in Desktop edition.Now I want the total fte count which is the sum of the fte counts at each grouped level.So I cant use the total as it'll give the grand total of all the line entries.But I am not finding any option for this kind of total.(Total of the subtotals)
    Pls give me a solution ASAP

    Hi,
    I am devoloping a report which pulls the expense lines for each project.I am displaying the fte count at each line.As it'll be same for a particular project,all the lines for that particular project will show the same FTE count.I am grouping the
    lines by Project No in Desktop edition.Now I want the total fte count which is the sum of the fte counts at each grouped level.So I cant use the total as it'll give the grand total of all the line entries.But I am not finding any option for this kind of total.(Total of the subtotals)
    Pls give me a solution ASAP

  • Average of the Grand Total in the Pivot Table

    all,
    I have calculated a Grand Total of sum 3 days trade in the pivot table using the Totals after in the Pivot table. I wanted to obtain the average of this Grand total. How can i achecive this in OBIEE 10g.? Please help urgent

    I did not understand your scenario exactly. Did you try using the 'newly calculated column' option from 'More options' of the particular column for which you want the average?.
    for example
    segment brand 1 value
    brand 2 value
    brand 3 value
    brand 4 value
    Avg brand per segment <value>
    notice that the 'Avg brand per segment' is a 'newly calculated item' where the average brand has been calculated. hope this helps.

Maybe you are looking for

  • Can I connect a thumb drive to my Mac on a Guest Account?

    My dad needs to use my Mac for an office presentation. He will use the guest account and present from a thumbdrive. Problem is, the Mac can't seem to detect it. Is the guest acount programmed that way? He really needs this.

  • Disable internal modem

    Got an iMac 333 with a defective internal modem. Am now using an external modem but needed to upgrade OS from 8.6 to 9.2. Upgrade went fine and the modem worked. My friend called me and now has the same problem...the OS wants to dial-out using the ol

  • Passing the queue name to the sender JMS adapter at run time..

    Hello Experts, I have a scenario where PI is to pick data from MQ queues. The message type coming from queues is same and the procession needs to be done with PI is also the same.That's the reason why we want to have only one interface processing the

  • How to check whether User is alreadylogged in or not

    Hi..I want to check whether Particular User is already logged in or not ?? I had userid,password and status in my database. If anybody shows me how to implement it ?? Reggards Chintan

  • Current Date Problem

    Hello, I'm admittedly a beginner user.  I'm trying to get a form to display the current date. I've followed the instructions in the Help file exactly, and everything seems to make sense, but all I get in the preview is a blank field. Hopefully it's a