Best Way to calculate totals from query

Could someone point me in the right direction to add up my
data and distinctly show it in my query?
I have a table with the following fields:
id, team_id, compname, teamname, totallost
I want to add up the "totallost" row where the "team_id" and
"compname" fields are the same...then show the compname with the
sum of the totallost once in my table and determine who is
winning.

Thank you for the great help. This code works well, but is
there a way to display the highest totallost and differentiate
between competition names? My example is for one compname, but the
table will have multiple compname's and I want to build a table
showing only the highest totallost for each compname.
You guys have been a great help. I learned something new
today already.

Similar Messages

  • Best way to spool DYNAMIC SQL query to file from PL/SQL

    Best way to spool DYNAMIC SQL query to file from PL/SQL [Package], not SqlPlus
    I'm looking for suggestions on how to create an output file (fixed width and comma delimited) from a SELECT that is dynamically built. Basically, I've got some tables that are used to define the SELECT and to describe the output format. For instance, one table has the SELECT while another is used to defined the column "formats" (e.g., Column Order, Justification, FormatMask, Default value, min length, ...). The user has an app that they can use to customize the output...which leaving the gathering of the data untouched. I'm trying to keep this formatting and/or default logic out of the actual query. This lead me into a problem.
    Example query :
    SELECT CONTRACT_ID,PV_ID,START_DATE
    FROM CONTRACT
    WHERE CONTRACT_ID = <<value>>Customization Table:
    CONTRACT_ID : 2,Numeric,Right
    PV_ID : 1,Numeric,Mask(0000)
    START_DATE : 3,Date,Mask(mm/dd/yyyy)The first value is the kicker (ColumnOrder) as well as the fact that the number of columns is dynamic. Technically, if I could use SqlPlus...then I could just use SPOOL. However, I'm not.
    So basically, I'm trying to build a generic routine that can take a SQL string execute the SELECT and map the output using data from another table to a file.
    Any suggestions?
    Thanks,
    Jason

    You could build the select statement within PL/SQL and open it using a cursor variable. You could write it to a file using the package 'UTL_FILE'. If you want to display the output using SQL*Plus, you could have an out parameter as a ref cursor.

  • Best way to calculate a duration

    Hi Everybody,
    loading data I have to calculate a key figure as a duration..it means as result from the difference between a start and end timestamps..
    how do you think would be the best way to calculate this keyfigure?
    I would rather prefer to do it in the update rule..
    I am going to appreciate any idea.
    Best regard,
    FedeX

    Hi
    It all depends upon the requirement. If you have a separate key figure in cube and you are calculating the value in update run it will increase the size on the cube a bit and loading process but will help to run the query fast. But if you create a calculated key figure on cube when you execute the query the value is calculated when query is running and increase query execution time.
    So it’s a kind of trade off to see how often you run query and often you load cube
    Thanks

  • How is the best way to remove something from a photo?

    How is the best way to remove something from a photo?

    This is difficult to answer without fully knowing what you are trying to do.
    That said, a few excellent and user friendly retouching tools include:  The Spot Heealing Brush Tool, Healing Brush Tool, Patch Tool, and the Cloning Stamp Tool.

  • How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

  • Whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    Check out > OS X Lion: How to use Migration Assistant to transfer files from another Mac

  • What could be the best way to Export data from 11.5.8 instance to 12.1.2?

    Hi All
    What could be the best way to Export data from 11.5.8 instance to 12.1.2?
    Release: 11.5.8
    OS: Oracle Solaris on SPARC (32-bit) verison 9
    DB: 9.2.0.1
    Thanks in advance

    What kind of data you are looking to move?
    Database export/import is only supported for full database export/import and the application release should be the same on the source/target nodes.
    You can move the setup using iSetup or FNDLOAD.
    Thanks,
    Hussein

  • What is the best way to import pictures from Lightroom 5 into FCP X

    What is the  best way to transfer pictures from Lightroom 5 into Final Cut Pro X?

    There is no one best way.  If, for instance, you want to be able to zoom into the picture with a Ken Burns effect then you may want to save out a very high res version that will be larger than your video resolution. Just use Lightroom to export a jpg file wherever you want it. You could export it into the Events folder and then choose not to copy it when you import it within FCPx. You could import the picture into iPhoto and then access it directly from within FCPx. Those are two simple, "regular" ways to get it into FCPx but if you are not going to Ken Burns the image by zooming into it and such you will want to crop it in Lightroom to the same size you will be using ie if you are making 720HD video then crop the image to that size and proportion before you export it from Lightroom.

  • What is the best way to import photos from aperture to my new Lightroom

    What is the best way to import photos from aperture to my new Lightroom ?

    See if this helps
    http://lightroomsolutions.com/articles/migrating-from-aperture-to-lightroom-where-do-i-beg in/

  • The best way to import photos from Picasa to iPhoto

    Hi,
    Many of my friends share their pictures online using picasa. Sometimes, I'd like to copy these pictures to keep a backup offline. As a software, I use iPhoto; not picasa. What is the best way to import pictures from picasa to iPhoto?
    I first tried to subscribe to the RSS feed using iPhoto and then copy the pictures from there to my library, but then the dates of the pictures are set wrong: instead of indicating when the picture was shot, it indicates some other date (I guess it indicates the date when the picture was uploaded to picasa).
    Then I decided to install the software picasa.app. From the webalbum of my friends, I could download the pictures directly to picasa.app. Then I exported them to the desktop, and from there imported them to iPhoto. The dates where set correctly, but I lost all the titles and comments of the pictures.
    Do you have any method to download the pictures while keeping both the dates and the titles correctly?
    Thanx!

    There is a direct option in Organizer which lets you import from iPhoto. This is under Import dropdown menu in left panel.
    If you are importing from iPhoto'09, your Tags, Albums Events, captions, star rating would also get imported apart from your media. This works differently for iPhoto'011 where you can get only the media to the Organizer,
    Just a couple of things to know:
    1. If in iPhoto preferences, you have chosen to create copies of your photos in iPhoto library and your library hence refers to the media store inside the library package, then on importing from iPhoto, Organizer would create copies of all those media under your pictures folder. That means, it would not corrupt your iPhoto package or modify it in any way.
    2. However, if in iPhoto, you are organizing by using references to original location on your Hard drive i.e. you are not creating copies of media in iPhoto library then on importing from iPhoto to Organizer, the Organizer would also use the same references and would not create copies of the media.
    Hope that helps!
    ~V

  • Best way to transfer files from old Macbook Pro to new one?

    I just got a new Macbook Pro from Apple...YEEEEAAAHHHH! 
    So....
    What's the best way to transfer files from old Macbook Pro to new one?  I know Migration assistant, but is there a recommended way?  I don't want to put do a system restore or transfer everything from the old laptop, but I do want to move important things like photos, music, documents and such over.  Any suggestions on best way to do this?
    Another question, perhaps subquestion.  If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?
    Just looking for hints from the experts so this puppy is set up in the best way possible.

    Just one comment on this:
    ‘If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?’
    the problems are ALWAYS in the reverse way, when you have the newest (or a newer) version of a given app, and wish to transfer its library to an older version.
    Otherwise, see the link to Pondini.
    I have been using Martin Jahn’s iBackup, with which I have become accustomed and works fine. It also makes daily backups. Its advantage over other apps is that you may add whatever you wish to save, beside its default settings (which you may delete or cancel, of course, even if not recommended); it also has a friendly interface and easily customizable. Of course, this is a personal view, you may try other methods as well, or other backup apps. All are good if you are satisfied and correspond to your needs.

  • What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?

    What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?
    I'm doing role reversal with these two.  The newer imac is becoming our business computer, the older one will be our personal computer from now on until it gives out.  For the record, I have Carbonite on the business unit.  Should be a no-brainer, right?  (Which is precisely why I'm asking!)
    Thanks for whatever timely and accurate advise you may have.

    Thanks. I stumbled across migration assistant later that afternoon in a google search. Just finished using it today to do the deed. Appreciate your quick response!

  • What is the best way to transfer files from a Power PC G4 that has NO power?  Thanks.

    What is the best way to transfer files from a Power PC G4 that has NO power?   I have a newer iMac. Thanks.

    Remove the hard drive and get one of these USB hard drive adapters. http://tinyurl.com/a5l2htj Then plug the adapter into your iMac to see/retrieve the files.
     Cheers, Tom

  • What is the best way to transfer data from a PC to an iMac?

    What is the best way to transfer data from a PC to an iMac?

    If you know how to set up a computer-to-computer Ethernet network, then you can give that a try, but a hard drive will be faster than Ethernet unless you don't have a lot to transfer.
    Mac OS X 10.6 Help- Creating a computer-to-computer network

  • What's the best way to transfer footage from a Sony miniDVD camcorder?

    What's the best way to transfer footage from a Sony miniDVD camcorder?

    Do not use "mini" DVD's in any slot loading DVD drive.
    Buy a cheap "tray loading" external DVD drive and attach it to your Mac.

Maybe you are looking for

  • ILife 4.0 will not install

    I have a G4 MDD 1.25 MHZ machine with OS 10.3.9. I am installing a new hard drive and installing all my apps fresh. I am trying to install iLife 4.0 but get the following message: iLife cannot be installed on this computer. This installation cannot p

  • New Iphoto wont open after downloading Yosemite

    I updated my 2010 Macbook Pro with Yosemite. Then I downloaded the new Iphoto from the App Store. The new iphoto is completely unresponsive and my old iphoto has a white circle with a line through it. Help!

  • Hd dvd authoring

    I have captured and edited a short clip from a Sony HVR-Z1E into FCP5. I am trying to get this clip into DSP4. I continually get "incompatible format" errors. In DSP4 i have the project set as HD and the "menus, tracks and slideshows" set as 1440x108

  • Net value missing

    hey friends need some help i am using the same pricing procedure for my sales order document and for Contracts. when i insert the condition type for price, the net value gets calculated for Sales order and the same doesn't happen when i am creating c

  • Direct Material Not Shown in Search Products/Services

    Hi , We are implementing Classic Scenario on SRM5.0. We replicated materials.The materials are shown in COMMPR01 with out Product Descriptions.When try to search for Materials under BBPSC02> Internal Goods/Services > Find Product, i don't see any mat