How to eliminate Duplicates

Hi
I have to sum the rows in a table eliminating duplicates(i.e for example I have TransactionID,Amount, as rows and the table name as TransactionTable). Now I have the TransactionID as 1000 and for this ID I have Amount as Rs.5500 in 6 rows and Rs.1100 in 2 rows in that table. Now when I query I have to get only
the value of 6600 for this query and not 35200 and Count should be 2 not as 8.
select count(*) as Count,NVL(SUM(Amount),0) from TransactionTable where TransactionID is 1000;
please help me in writing the query.
Thanks & Regards
Sudheer

hi,
try this
with t as
(select 100 id,5500 amt from dual union all
select 100 id,5500 amt from dual union all
select 100 id,5500 amt from dual union all
select 100 id,5500 amt from dual union all
select 100 id,5500 amt from dual union all
select 100 id,5500 amt from dual union all
select 100 id,1100 amt from dual union all
select 100 id,1100 amt from dual
select count(*), sum(amt) from (select distinct id,amt
from t)
/

Similar Messages

  • How to Eliminate Duplicates in Hibernate Criteria Query

    Hi all,
    Anyone who know how to eliminate duplicates in Hibernate Criteria Query ?
    Thanks,
    Lanz

    You should try asking this in a hibernate forum

  • How to eliminate duplicates when merging photos?

    How to eliminate duplicates when merging photos?

    OK, time to move over to the Aperture Discussions Group.
    It's at this link - https://discussions.apple.com/community/professional_applications/aperture
    This group you are in now is for Lion discussions, and over in the Aperture group, you'll meet skilled people who will help.  Especially if you state your questions clearly and provide sufficient context such that the reader can figure out what is needed.
    Make sure you spend some time reading the Aperture User Guide before asking really basic questions, and search the PDF version using Preview.
    Also search that group for your question, it may well have been asked and answered

  • How to eliminate duplicates from multiple subscriptions in iCal?

    Is there a way to eliminate duplicate entries created when subscribing to multiple calendars?  As an example - I have a subscription with each of my kids school calendars (one is in middle school the other elementary). I end up with several duplicates such as the following: 
    February 14, 2014
    * Valentines Day (calendar)
    * Valentines Day (elementary)
    * Valentines Day (middle school)
    Thanks for your help!
    -Curt

    Your specification can be interpreted more than one way.
    In the examples you give, "duplicate records" not only have the same EMPNO, but all the data is the same. If this is what you are trying to avoid, use DISTINCT. Instead ofFROM EMP_TEST Ewrite FROM (select distinct * from EMP_TEST) EThis will eliminate duplicates if and only if every column has the same value.
    Again, not sure if this is what you want but it would work for your sample data.
    P.S. I agree with sb92075, you should make EMPNO a primary key and avoid the problem altogether.

  • How to eliminate duplicate copies after doing a sort

    I did a filter/sort across 100's of folders then exported the results to a separate folder.
    I later noticed way too many duplicates in the new folder.
    Does Lightroom have a feature to automatically remove or eliminate duplicates when doing such a process??
    If not, any other ideas??

    Spaceman, you're basically correct that LR doesn't write your changes to the original file itself.  LR is a non-destructive editor, which is really a good thing. It means that if you screw up an edit, you can always go back and start over. Or if you decided to convert the image to B&W, and now want to go back and re-edit it in color, you can do that. There are, however, a couple of ways to do what you want.
    The easiest way is to use the Export dialog. This will create a copy of your image(s) with all the edits applied. Those copies can then be viewed in any image viewer program. You can export as jpeg or tiff files. Based on your question, I'm guessing you typically shoot and process jpeg files (since most image viewers won't display raw files), so LR will create new jpegs, with all your edits. You can give these files new names on export, or write them to a different folder. You can even automatically import the images into the LR catalog if you want. (I don't, as if I ever want to re-edit the images I'll start with the original file.)
    LR can also write the changes to what's called a "sidecar" file, that you can copy along with the original image file.  But I don't think very many apps know what to do with that file, either.

  • How to eliminate Duplicate photos in I-Photo as I now have Snow Leopard

    Problem to Solve: I loaded from my both memory chips and also from my camera, many photos from a long trip. I was concerned to delete prior from the chip to loading on my IMac, after loading during trip to my MacBook. Now I have about 5,000 duplicates or more, which is taking up a lot of GB space on my HD
    Aside from going thru one by one, is there a way the computer can find the duplicates and eliminate one of them or two of them etc.
    Please help
    Steve in Nantucket

    TD Great going
    I bought the full version
    It days DAYS to go thru all77000 photos found dups found thus far4757
    10.56 GB
    Balance time estimated is 2 day and 7hours
    34,000 to go
    Tank you for your assistance
    Another funny items
    While I traveled my laptop logged in website etc
    Now when for example i ask for yahoo
    it comes up
    http//m.www.xxxxxxxxxxx
    What is the M ???
    Steve

  • How to eliminate Duplicate Email Messages in my Hotmail account

    I've noticed that sometimes when I'm checking my Hotmail inbox on my phone I will have duplicate emails of some messages (but not all). Sometimes it will be 2, 3, 4, or even 5 copies of the exact same message (the number seems to vary depending on the day). Sometimes the duplicates are on a string of messages all from the same time frame while other times I only get a single copy of my emails. I can't seem to figure out the pattern of when I get the duplicates. The only thing I am starting to suspect is that perhaps it has something to do with going from one WiFi to another or from WiFi to the 4G network (that maybe it is downloading the messages each time my phone gets on a different network??) Does anyone know how to fix this so I don't get duplicates on my phone? I don't see the duplicates in the Hotmail account Inbox when I log in from my computer, just on my phone.
    Also I can't seem to get to the settings like I could on my Droid X where I could indicate that I want to delete the messages from the Inbox if I delete them on my phone. Is it hidden somewhere or is there a trick to making that work? I don't like having to manage my Inbox in TWO places. I'd like to be able to delete it either on my phone or on my computer and have that message deleted in both places.

    SG67 wrote:
    Also I can't seem to get to the settings like I could on my Droid X where I could indicate that I want to delete the messages from the Inbox if I delete them on my phone. Is it hidden somewhere or is there a trick to making that work? I don't like having to manage my Inbox in TWO places. I'd like to be able to delete it either on my phone or on my computer and have that message deleted in both places.
    Are you using the stock e-mail app?  If so, try going to your e-mail, then clicking the gear (for Settings).  In your Hotmail account, scroll until you find the Incoming Settings, then change Delete E-mail From Server to your preference.

  • How to eliminate duplicate calendar entries after sync with iCloud ?

    I just upgraded my iPhone 4 to IOS5 and set up sync through iCloud. Now all my iCal entries appear twice on the iPhone, even though they appear only once on my Mac mini (running Lion).
    How do I stop this happening? And how do I get a clean calendar on the iPhone?
    Neil

    Ok, I solved my own problem. I thought I had unchecked "Sync Calendar" in iTunes on the Mac mini, but it turns out I had not. As soon as I unchecked that box and let the system delete that calendar, all the duplicate entries went away.
    Neil

  • Using duplicate annihilator: How to eliminate duplicates once found?

    OK, I purchased the full version of duplicate annihilator and it found the duplicates. What's the rest of the proceedure to delete the duplicates?

    If Duplicate Annihilator has given them all a keyword "Duplicate" then a smart album
    Keyword is duplicate
    will find them.
    Has the Help in DA anything to offer?
    Regards
    TD

  • How can eliminate duplicate emails with mail forwarders?

    On 10.6 server.
    We have multiple users complaining about getting two copies of some emails when the emails are sent to both their individual accounts and the group forwarder account that is also on the server. Is there any way to eliminate this or am I stuck? Is there some kind of group email in WGM or postfix? Are there options somewhere for "remove to and cc from distribution" like options for forwarders?
    Thanks.

    Information on trying to get Mail and Gmail to work together.
    Gmail with Apple Mail
    Gmail with Apple Mail (2)
    Gmail with Apple Mail (3)
    Gmail with Apple Mail (4)
    Gmail with Apple Mail (5)
    Gmail without duplicates

  • How do i eliminate duplicates in itunes 11?

    how to eliminate duplicate songs in itunes?

    Simbalover wrote:
    You don't have to delete them. Go to Preferences >> Store >> Uncheck show itunes in icloud Purchases.
    Didn't work (but I left it unchecked anyway).
    All of my duplicates are from CD's that I own and imported myself, not purchased through iTunes.

  • How to eliminate du[licate rows in oracle

    dear forum members,
    this is madhav,
    i come up with a problem that, how to eliminate duplicate records in table containing huge(laks) duplicate records.
    And remember u should not use 'rownum' and 'rowid' in ur query and you should not use moving distinct rows into a new table and drop the old table and rename the new table with old table name. and ofcourse your query should be efficient.
    please come up with a good reply .....please it is urgent..

    Use a RowID in Oracle and an Identity column in SQL Server.
    http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=3385

  • How do I eliminate duplicate email accounts on my Mac?

    how do I eliminate duplicate email accounts on my Mac?

    Go to Mail Preferences/Accounts.  Select the Account you want to remove and hit the minus button.

  • I must have many duplicates over 10,000 photos-impossible! How can I find and eliminate duplicates

    How can I find and eliminate duplicate photos? iPhoto says I have 10,000 or more images which cannot be!
    I assume as I imported them from various discs, cameras etc there overlap?
    Thank you

    Some apps for dealing with duplicates in iPhoto
    iPhoto Library Manager
    Duplicate Annihilator
    Decliner
    iPhoto Duplicate Cleaner

  • How do you eliminate duplicate iphoto photos?

    How do you eliminate duplicate iphoto photos?

    There are two apps, actually one app and one Applescript script, for finding and removing duplicate photos from iPhoto. They are:
    Duplicate Annihilator
    iPhoto AppleScript to Remove Duplicates
    OT

Maybe you are looking for