Totalling rows that have a 'sum' calculation in them

I would like to report a single row for each 'cardcode' (I know there is only one at the moment) but as each row already has a 'sum' calculation in it I am not sure how to do this, any ideas please?
The idea is to report only a total sales value per customer on one row for the given time period
SELECT
t1.cardcode as 'Code',
t1.cardname as 'Name',
t1.docnum as 'Document Number',
sum(t0.price) as 'Sales Value'
FROM
rdr1 t0
inner join ordr t1 on t0.docentry = t1.docentry
WHERE
t1.docdate >= '[%0]' and
t1.docdate <= '[%1]' and
t1.cardcode = 'ALL006'
GROUP BY
t1.cardcode,
t1.cardname,
t1.docnum
Thanks,
Robin

Hi Robin,
try this one. Instead of OINV you also can use ORDR:
SELECT T1.[CardCode], T1.[CardName], SUM(T1.[DocTotal]-T1.[VatSum]) AS 'Sales Value'
FROM [dbo].[OINV]  T1
WHERE T1.[DocDate] BETWEEN [%1] AND [%2]
GROUP BY T1.[CardCode], T1.[CardName]
Of course, you will find a standard report in the Sales / Reports. There you can display sales value for customers on a given date range. Why do you want to create a query?
Regards Steffen

Similar Messages

  • Totals column that is the sum of all the data columns

    In a Report, I have several data columns, and then I want a totals column that is the sum of all the data columns. So for every row, the totals column will show the total of the data columns. How do I do this?
    Thanks, Wayne

    One way, create CF_total:
    function CF_totalFormula return Number is
    n number;
    begin
    select sum(coll) + sum(nvl(col2, 0)) + sum(col3)..... into n
    from tbl;
    return n;
    exception
         when others then
         return null;
    end;
    Another way, if you have SUMCOL1, SUMCOL2, ....:
    function CF_totalFormula return Number is
    begin
    return :SUMCOL1 + SUMCOL2 +.....;
    end

  • Is there a way to import images that have been edited and assign them to the original?

    I am transitioning to mac and aperture. Is there a way to import images that have been edited and assign them to the original? I have 10,000 originals and about 2,000 edited images. The originals are named img_XXXX and anything modified img_XXXX_modified. I would like to be able to import the originals and then import the edited versions and assign them to the original masters. Instead of starting from here and going forward with 12,000 masters, some of which are actual originals and others not. Thanks for the help.

    Ah, the vestiges of a destructive workflow! Once you "get" Aperture, (specifically Masters and Versions) you are going to love it, as all of this work goes away - the relationship that you seek to retain is automatic in Aperture; it is simply done differently.
    The short answer to your question is EVERY image file that is Imported into Aperture will create a new Master and one Version. Assuming that your images are PSD/TIFF/JPEG that you created in something like Photoshop, then each one that your import will be a new Master. You have many options:
    -- Stick the originals in one Project(s) and the edited versions in another Project(s).
    -- Stick them all in the same Project(s) and "Stack" them.
    But here is the real question: Why are you doing all of this work and what are you trying to accomplish? Seems you are trying to preserve old things that don't need preserving in a non-destructive workflow.
    So, what is most valuable to you?
    -- The original, out of camera files? (That is, the fear/need to revert.)
    -- The edited versions? (That is the hours of work that it took you to get there.)
    If the former, import the originals and ignore the edited versions. (Either simply leave them out on disk or import them into their own Projects which you ignore.) Use Aperture to recreate the work you had done previously. This will always give you the ability to revert to the original Master and create as many Versions as you want. This is the best idea if your edits are relatively simple crops and exposure adjustments,
    If the latter, then import the edited versions and do as above with the originals. This makes more sense if your work uses lots of layers and, perhaps lots of clone tool type corrections.
    Of course, you can do a bit of both.
    Others may have better suggestions, but you will find it easy to answer your own question when you understand an image based, as opposed to a file based, non-destructive workflow.
    Good luck!

  • My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters are showing up as green, which is fine in the chapter but not in the TOC.

    My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters, specifically parameters, are showing up green, which is fine in the chapter but not in the TOC. I can manually fix this in the TOC by changing the character style to none after the toc  has been generated, but I don't want to do this.

    What application are you running? Please ask this in the forum of the product you're using.

  • How to use EWS or Powershell to rename all folders that have a forward slash in them

    We have many users that have created folders in Outlook that have forward slashes in the name (i.e. / ). They did this in Outlook/Exchange 2003. We upgraded to Outlook 2010 and this is no longer aloud so there are issues with the folders when performing
    functions such as trying to share or using IMAP, etc.
    I'm looking for a way to specify a particular user's mailbox in a script and have it traverse every folder/subfolder and check if there is a forward slash in the name. If there is a forward slash I would like to rename the folder to something like the bar
    character (i.e |) or another character that is valid.
    I had most users go through Outlook manually and clean them up. However there are a handful of users that have hundreds if not thousands of subfolders that have the forward slash in them.
    I've done extensive research on this (references to my research below) and came close in putting a script together but I just can't figure it out. Anyone have an example for this? Even if I need to specify a folder within the Inbox and have the script only
    process subfolders from this location would be acceptable since most of them are subfolders of a particular folder.
    Thank you.
    http://social.technet.microsoft.com/Forums/exchange/en-US/b24d0558-ed6a-4854-9a86-e9815741b5d0/rename-folder-example-in-ews?forum=exchangesvrdevelopment
    http://exchange-powershell.com/database-management/bulk-public-folder-rename-and-cleanup-script/
    http://unlockpowershell.wordpress.com/2010/10/14/powershell-rename-a-mailbox-folder-using-exchange-web-services-api/

    First two articles are for public folders so it won't help here as you have mailbox folders...
    http://unlockpowershell.wordpress.com/2010/10/14/powershell-rename-a-mailbox-folder-using-exchange-web-services-api/ 
    This is good starting point, you might need to change the logics around it  to search / and replace with - or someting, this might be the code change needed from that article but would suggest you to test it first.
    foreach ($folder in $ffResponse.Folders)
    if ($folder.Displayname -like “*/*”)
    Write-Output “Found / in the $mailboxName and folder name is $folder.Displayname”
    $folder.Displayname.Replace("/","-")
    $folder.Update()
    Blog |
    Get Your Exchange Powershell Tip of the Day from here

  • How to find PDF files that have other documents bundeled within them?

    Hello guys
    I need help with the following: we have a huge number of PDF files that have other documents imbedded (bundled, attached) in them. If such a document is open in Acrobat, bundled files show up as attachments on the left. Some of those attachements are .mdi files. This is Microsoft Document Images files. Is there a way to flag PDF's that have those .mdi files in them? I need to find them and convert to PDF. If I need to be more descriptive please ask, and thank you in advance for help.

    Preflight is a complex plugin, it's hard to explain how to use it in one forum post. You need to read the documentation carefully.
    There's no pre-built profile for what you want, so you would first create a new Custom Check that compares the MIME type string of embedded files to what you're searching for (not the file extension but the full MIME identifier, which for Office files is a very long string). You would then place that new Custom Check into a new Profile, identifying it as an error condition. Once you've saved the Profile you can run it against a number of files and specify actions to be taken for pass and fail conditions, such as changing the filename or moving to a subfolder.

  • Apps downloading in background that have already updated? Pause them in Launchpad but keep on at it!

    apps downloading in background that have already updated? Pause them in Launchpad but keep on at it! At this rate my ISP will cap me.

    Divine88 wrote:
    I have Recently been trying to update several apps of mine, and when i click update all, or one at a time, it takes me straight to my billing information.
    That's because the billing information is out of date or there was a problem with a previous purchase.
    Then after that it says i need to pay to update my apps that have already been purchased or apps that i have gotten for free
    No. That's not what it says. What is the EXACT message you get?
    However, when i took my iPhone 5 with iOS 7.1.1  to the apple store, the "geniuses" have told me i have outstanding payments on an app so in order to update them, i need to go and purchase more itunes cards.. So i have went out and bought about Three 20$ itunes cards hoping that by using just 1 card - it would fix the problem im having. but it isnt.
    Contact iTunes store support and find out what the problem is.
    ALSO if i purchase an app without having the same amount of what it costs it will not let me buy/download it
    Um... yeah... That's the way it works. If you want to buy something, you have to have enough to actually pay for it.
    Contact iTunes store support.
    You're not talking to Apple.  This is a user forum.

  • TS4124 there are lots of songs that have no icon next to them. What does this mean?

    there are lots of songs that have no icon next to them. What does this mean?

    I'm going to take a guess that you are referring to iTunes match in iTunes on your Mac. (as in the screenshot below)
    Tunes without symbols, mean that the file is stored on your Mac.

  • Tally up a column only on rows that have been checked

    Hi I'm driving myself to drink with this, and I'm sure it should be pretty easy.
    I have a subtotal column (Column D) which I calculate the total of via (SUM(D2:D20), however I have a column G, that is a "Paid" column, that has a checkbox, now what I want to do is only tally up in column D the amounts that have been ticked/checked in column G.
    I thought SUMIF would be my solution but it's not working.
    I've tried the following among other things and nothing works.
    =SUMIF(D2:D20,TRUE)
    =SUMIF(G2:G20,TRUE,D2:D20,)
    Any help would be most appreciated.

    =SUMIF(G2:G20,TRUE,D2:D20)
    works perfectly.
    In your message there was an extraneous comma but I don't know if it was available in your sheet or if it was just a typo.
    If you are running Numbers in English in a country whose decimal separator is comma, you will have to edit the formula like that:
    =SUMIF(G2:G20;TRUE;D2:D20) (semi-colon replacing comma).
    Yvan KOENIG (from FRANCE samedi 19 juillet 2008 20:47:27)

  • Delete rows that have been dropped in a CDC flow

    Post Author: sgsampey
    CA Forum: Data Integration
    A newbie question:
    I have a source table called Events with (significant) fields that look like:
    EventIDEventNameBeginDateEndDateDaysOfWeekModifyDate
    These data ranges can be quite long, and there's an exception table if the Event isn't being held on a given day
    ExceptionIDEventIDExceptionDate
    I need to flatten this data into a target Event_Instance table of individual days:
    EventInstIDMasterEventIDEventNameDateDayOfWeek
    I'm going to populate the target by combining Event source (filtered by modify date to only grab updates and additions) with a SQL table that creates a range of days, join that with the exception table, and filter based on no match in the exception table. That part's easy.
    The problem I'm having is what do do when an Exception is removed or updated (Events are never removed - just canceled). There's no ModifyDate to look at. I know I need to create a buffer table to track changes, but once I identify execptions (in a Query Transform) that have been added since the last ETL, I don't see how to remove those Event_Instances. The two only solutions I can come up with is to wipe the entire Event_Instance table and rebuild with every ETL, or to add an 'action' field to Event_Instance, updateit to 'D' for those rows that need to be removed and then execute a SQL command to delete those rows once done.. I know there must be a better, incremental way to do this. TIA!

    Your Mobileme galleries should be listed in the library pane on the left. How about creating a new album in the main library and dragging the images from a gallery to the album. Then delete the gallery and recreate it from the album.

  • Displaying the rows that have been updated....

    SQL> select * from spr;
    EMP_NAME EMP_no age sex
    hry 45353 42 M
    spt 43436 34 M
    pen 34533 21 M
    aen 65475 33 M
    SQL> select * from sprfac;
    EMP_NAME EMP_no age sex Appraisal Extra_Time
    hry 45353 N N
    spt 43436 N N
    pen 34533 N N
    aen 65475 N N
    I have a problem regarding updating the sprfac table.
    What i need is to satisfy the following conditions and update the second table with values in the second table.
    I need to upadate the second table when:
    1. The emp_name and emp_no of first table matches with the second table and
    2. The Appraisal field and extra_time field should be 'N' in the second table and
    3. only if the values of age and sex are NULL.
    Let me explain in detail.
    My original table is sprfac. spr is Temporary Table.
    I have some data in flat files and i have loaded all the data into a temporary table using sqlloader. Now i need to update the second table.
    Originally the age and sex fields in the sprfac table are NULL. Once i update the age and sex fields in the sprfac table again if i do update it should not update the rows which have data in age and sex columns.
    Suggest me how to update multiple columns simultaneously or send me the code for the update statement if possible.
    NOTE: I have changed the tablenames and column names since i cannot keep the original tables here.
    And i got the following reply........
    update sprfac a
    set (a.age, a.sex) = (select b.age, b.sex from spr b
    where a.emp_name = b.emp_name
    and a.emp_no = b.emp_no
    and appraisal = 'N'
    and extra_time = 'N')
    where a.age is null
    and a.sex is null;
    Everything is working fine.
    Is there any way to send the name and age fields which have been updated of sprfac to a file.
    should i use cursors....
    Send me the code if possible....
    Thanks..........

    You can try similar to this, if you have oracle 9i. In 8i merge does not work. In that case u have cursor.
    merge into EMP e1
    using akg_emp e2
    on ( e2.empno = e1.empno AND e1.sal > 1000 AND <whatever condition on e1>)
    when matched then
    update set e1.sal = 100
    when not matched then
    insert ( empno, ename, job, mgr, hiredate, sal, comm, deptno )
    values ( e2.empno, e2.ename, e2.job, e2.mgr, e2.hiredate, e2.sal, e2.comm,
    e2.deptno )

  • Extract only records that have difference sum

    Hi all. I'm on oracle 10g.
    I have a question. I have two select statement, both with sum function.
    I want that from first select I must retrieve only records which have different sum.
    Here is the code:
    first select statement
    select a.codice_contratto codice_contratto, a.codice_qualifica codice_qualifica,
    a.codice_istituzione codice_istituzione, sum(a.nume_dip_tot) tot, sum(a.nume_dip_donne) donne
    from tn_bz_t_10 a
    where a.anno = 2006
    group by a.codice_contratto, a.codice_qualifica, a.codice_istituzione
    order by a.codice_contratto, a.codice_qualifica, a.codice_istituzione
    secon select statement
    select codice_contratto, codice_qualifica,
    codice_istituzione,
    sum(nume_dip_tot17) tot, sum(nume_dip_donne17) donne
    from tabella10
    where anno = 2006
    and versione = 'D'
    and nume_dip_tot17 <> 0
    group by codice_contratto, codice_qualifica, codice_istituzione
    order by codice_contratto,codice_qualifica,codice_istituzione
    My goal is that from first select I must retrieve only those records which have difference sum, tot or donne,
    from second select...
    How can I achieve that??
    Thanks all for collaboration,
    Fabrizio Delli Priscoli
    Edited by: Fabrizio Delli Priscoli on 23-set-2010 14.25

    Hi, Fabrizio,
    (1) an inner join, or
    (2) NOT IN
    are two ways that will probably be efficient.
    You've been using this forum for nearly 9 years, so you know that, to get a more detailed answer, you need to post a more detailed question.
    Post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Format your code and results, and post them between \ tags to keep this site from removing the extra spaces.
    Always say what version of Oracle you're using.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I cannot import particular cds that have a media player on them.

    I have two cds magic numbers and the chilli peppers which already have a media player on them. When I put them in they start playing with the media player on the cd this means itunes does recognise them and I cannot therefore import them.
    Any ideas how to override the media player on the cds?

    Sounds like you have "protected" CDs that were designed to prevent music transfers.
    Depending on who put them out and when (If they date back to the great Sony rootkit debacle, and were put out by Sony, you've got some nasty software now installed on your computer and this won't work.)just holding down the shift key when you put the CD in the drive will disable the media player and, for now, disable Auto-Run.

  • Once more - tabular form / update only rows that have changed

    I know it's been asked before, but I haven't seen an answer I like. :-)
    I have a query that includes a single column the user can update, using APEX_ITEM.TEXT(10, updateable_field, 10, 10)
    I have an additional APEX_ITEM.HIDDEN(21) and APEX_ITEM.HIDDEN(22) that hold the two fields of the composite primary key. In order to track whether my updateable_field had changed, I created APEX_ITEM.HIDDEN(11, updateable_field), which I expected would hold the OLD value of the field. See where I'm going with this? :-)
    I'm attempting to loop through apex_application.g_f21, get the values for F10 (new) and F11 (old) and compare them. If they're different, I'll do the update.
    It works fine if the old value (F11) is empty and I plug in a new value (to F10).
    But if I change a field that had already has a value (in F11) and make it NULL, I notice that F11(i) doesn't exist. In that case, I set the value to NULL, and the compare fails because it thinks the row is unchanged.
    Can someone suggest or point me to an alternate method that works?
    Thanks as always,
    Stew

    Mike,
    Thanks for the suggestion, which is a good one. But I had that one covered.
    I have it working now, and I believe the fix was that I moved the APEX_ITEM.HIDDEN that contained the old value in the query. I'd had it concatenated with the column for the new value (which used APEX_ITEM.ITEM). I changed it to concatenate to a plain string value. And now the array has values in it, which I can properly compare.
    Thanks again. That was really driving me nuts!
    Stew

  • Rows that have errors in a batch

    How does one determine which insert/update/delete statement in a batch
    has a sql error? I am using the Oracle model of batching which is working fine but
    when I get an error I don't know which row
    had the error.

    Hello there dmedara,
    I believe I have the perfect article for you. Named iTunes: How to resume interrupted iTunes Store downloads it can be found here http://support.apple.com/kb/ht1725?viewlocale=ko_kr.
    Resuming downloads from a computer
    Open iTunes.
    Choose Store > Check for Available Downloads.
    Enter your account name and password.
    Click the "Check Downloads" button.
    Click the Resume or Resume All button, or the resume arrow to resume the download.
    If you believe that the item downloaded completely but it is not appearing in the Purchased playlist, click Library on the left side of iTunes to see if the item appears there.
    You can also check your purchases to download it from there as well.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/ht2519
    Cheers,
    Sterling

Maybe you are looking for

  • Device caching with Flash Lite

    Hi, could anyone give me some info on content caching when using Flash Lite on a device? I have some swf's that sit on a server and are loaded by a client.swf that sits on my Nokia N70. Each of the swf's from the server use shared fonts that reside w

  • How can an Oracle9i Lite DB receive connections via JDBC?

    I have not really experienced with accessing Oracle from Java, so here is a short description of the problem: I haven't yet figured out how is a database listening for connections. I think that the use of Listeners is for this job but I have not yet

  • Keyword Heirarchy - move/rearrange keywords

    I would like to see a tool to make it easier to rearrange your keyword hierarchy. *NOTE* This stems from the fact that importing from Elements jumbled my extensive set of keywords. The only way I see to move them around to the hierarchy I desire is b

  • My ipad died while i was working on a project when i turned it back on all my work was deleted how d

    my ipad died while i was working on a project when i turned it back on all my work was deleted how do i get it back?

  • Sending file to br printed

    I am working on a program that needs to be able to print some files. It should just be able to select files from a list and it should be able to send them to the printer (without opening them). To complicate matters more these files to be printed are