Want to avoid cartesian Product but cannot avoid it some how.

Hi,
I am using oracle 10G .
trying to draft a query which is resulting in absurd results.
select i.corr_acc_no, sum(amtsign.amount_6) from item i,
(select corr_Acc_no,flag_2,decode(fund_code,'C',amount_6,amount_6*-1) amount_6 from item
where corr_AcC_no in (select corr_acc_no from bank where local_Acc_no in ('MBL-SEG-NZD'))and flag_2=0) AmtSign
where i.corr_acc_no=amtsign.corr_acc_no
and i.flag_2=0
group by  i.corr_acc_no
Basically the inner query, which i am using as the second table in the join, gives 13 results. I want to sum the amount_6 field in main select clause which I want to get from results of
(select corr_Acc_no,flag_2,decode(fund_code,'C',amount_6,amount_6*-1) amount_6 from item
where corr_AcC_no in (select corr_acc_no from bank where local_Acc_no in ('MBL-SEG-NZD'))and flag_2=0)
The sum took too much time so i drafted simple query to check how many rows are returned by removing sum and i noticed it gives a Cartesian product with 169 rows instead of just 13. I have 2 join conditions but the value for corr_Acc_no is same for all 13 rows, i can't use amount_6 as join becuase i am changing it's sign  in the inner query. Please advise.

Thanks to both of you. @LakmalRajapakse your answer is bang on right. I did the same way after I posted this. I realized there's no point joining item with itself when I can get it done in single query. It's just that I was having hard time with 'Case' in select to get whatever I want,so I tried this logic. But then gave a try to decode, it worked. Thanks anyways.

Similar Messages

  • HT3743 I purchased an iphone 3g that was to be open to any carrier, I went to restore it to my itunes account and get a 1015 error, can this be fixed.  I am new to the iphone and like the product but cannot buy new.  Please help. THANKS

    I purchased an iphone 3g that was to be open to any carrier, I went to restore it to my itunes account and get a 1015 error, can this be fixed.  I am new to the iphone and like the product but cannot buy new.  Please help. THANKS

    You got ripped off. You bought a hacked/jailbroken phone. That's what error 1015 means. Return it and get your money back if possible and buy a phone from a legitimate source.
    Discussing jailbroken / hacked phones is forbidden by the terms of service. Jailbreaking / hacking voids any warranty and forfeits your right to support here or from Apple. You can not get help here.

  • When i go into history to delete everything but when i go to type site it comes up and name and password are saved i want to delete all this but cannot

    Question
    when i go into history to delete everything but when i go to type site it comes up and name and password are saved i want to delete all this but cannot edit

    Quote from the article.
    Time Machine in OS X Lion includes a new feature called "local snapshots" that keeps copies of files you create, modify or delete on your internal disk. Local snapshots compliment regular Time Machine backups (that are stored on your external disk or Time Capsule) giving you a "safety net" for times when you might be away from your external backup disk or Time Capsule and accidentally delete a file.
    So what makes a notebook any different then a desktop, other then with a desktop you might have your tm backup drive connected all the time.
    The object here is to not indiscriminately delete files you need or want to keep. I personally have never deleted a file I wanted to keep.
    In essence a backup is for catastrophic failure of your system. So it can be restored once that failure has been fixed. Not because you go in willy nilly and start deleting files.

  • HT1918 hee guys how do u delete a creditcard from your apple id? in the summer a friend of mine connected his own creditcard details to my apple id now i want to disconnect that again but i have no idea how? i just want my own apple id without a creditcar

    hee guys how do u delete a creditcard from your apple id? in the summer a friend of mine connected his own creditcard details to my apple id now i want to disconnect that again but i have no idea how? i just want my own apple id without a creditcard connected to it

    I own the movies and I want them to stay in my iTunes library basically forever.
    But in both cases the file name no longer shows in the movie list, so I don't know how to re-download it from the Cloud.
    iTunes prefs > Store > Show iTunes in the Cloud purchases.
    This will show all your iTunes purchases in your library with a cloud icon down arrow. Click the icon to redownload or click on Play to stream without downloading.
    Also see this , -> Download past purchases
    and techncially, you don't "own" the movie, You simply have a license to use it.
    Yet the first thing iTunes does when you hit the delete key is tell you that it will remove the movie forever from all devices and the library.
    Actually, no it does not tell you that.
    FYI: You should keep copies of all yoru iTnue spurahses as the labels/movie studios/copyright owners can pull their product at anytime and it won't be available to redownload.
    Suggestions here -> http://www.apple.com/feedback/

  • I am using iphone...i want to reset my phone but i forgeted passcode.then how can i reset it ?

    i am using iphone...i want to reset my phone but i forgeted passcode.then how can i reset it ?

    If you cannot remember the passcode, you will need to Restore the device...
    Connect to iTunes on the computer you usually Sync with and Restore...
    http://support.apple.com/kb/HT1414
    If necessary Place the Device into Recovery mode...
    http://support.apple.com/kb/HT1808
    Once you have Recovered your Device...
    Re-Sync your Content or Restore from the most recent Backup...
    Restore from Backup
    http://support.apple.com/kb/ht1766

  • How to remove stocks, weather,clock, notes, reminders, youtube, game center calc, voice memos,calendar, maps, and stocks? As a person who blew 300 bucks I think I should have a choice if I want to remove this crap but can't figure out how.

    How to remove stocks, weather,clock, notes, reminders, youtube, game center calc, voice memos,calendar, maps, and stocks? As a person who blew 300 bucks I think I should have a choice if I want to remove this crap but can't figure out how.
    any help would make me happy. As it stands now from looking on the web it can't be deleted but making sure before i return this ipod touch. I wan't a clean item the way I wan't it and not how they want it. Like I do not need Itunes and App Store on this ipod because I use my computer only to shop, So many things i like out of the ipod and I am sure lots more people also would like a cleaner ipod/phone or what ever.
    from looking at what I never use I see a total of 14 app's I not want taking up space and my screen.
    yup with the 5.0 came another stupid icon i not like. ( Newsstand )

    yes i moved them into a folder, but I not want them at all on my screen. Guess I return this and pick up a
    Zune HD
    less app's on that then ipod touch. thank you for the responce.

  • I have downloaded my albums to new ipod (second one) but cannot download purchases. How do I do it?

    I have downloaded my albums to new ipod (second one) but cannot download purchases. How do I do it?

    If your iPod classic has enough storage capacity to hold your entire iTunes music library, here's one convenient way to do set it up to sync "everything" automatically, including any new changes.
    First, if your iTunes sidebar (along left side of window) is not visible, from the menu bar, under View, select Show Sidebar.
    Select the iPod in the sidebar, under DEVICES.  Near the top, there is a bar of buttons, starting with Summary.  Click on Music next to Summary.  This is the iPod's Music screen, where you tell iTunes how to sync songs to your iPod.
    Check the box fo Sync Music.  NOTE:  If there are songs on the iPod that are not in your current iTunes library, those songs will be lost when you set up automatic syncing.  If this is a problem, please post back.
    Choose the option to sync Entire music library.  With this setting, when you click Apply, your entire iTunes music library syncs to the iPod, including playlists.  Going forward, any changes you make to your iTunes music library sync automatically to the iPod, the next time you connect it (or click Sync if the iPod is already connected).
    This document has general info on syncing content to iPods
    http://support.apple.com/kb/ht1351

  • It is saying my voicemail is full and it isn't. I do not want to erase my messages, but I do not know how to fix this problem. Can someone help me?

    It is saying my voicemail is full and it isn't. I do not want to erase my messages, but I do not know how to fix this problem. Can someone help me?

    heymare66 wrote:
    The phone usually can hold 24 messages before the voicemail is full, but now I have only 21 and it's saying it's full.
    I think your Voice mailbox goes by time, not # messages, so if one or two of the messages is longer, then it would be "full" faster.
    Go to youmail.com and follow the directions to set up youmail.
    Just curious - why do you need to save 20+ messages?  Once I deal with them, I delete them.... and I rarely have more than one or two \saved messages....

  • I just brought Lightroom 5 via online, but cannot support by MAC, how come?

    i just brought Lightroom 5 via online, but cannot support by MAC, how come?

    Serial numbers for LR are cross platform and CC memberships also are cross platform.
    You can download Lightroom's latest update here for Mac: blogs.adobe.com/lightroomjournal/2014/11/lightroom-5-7-now-available.html
    Regards

  • When I Backup iphone 5s and i want to restore my photo but It doesn't work.How can I do friends thank for your answer

    when I Backup Iphone 5s and i want to restore my photo but It doesn't work.How can I do friends thank for your answer

    What do you mean it doesn't work?
    Are you getting an error message?
    ~Lyssa

  • I want to start lifeCycle Es but I don`t know How to install it on my computer, Can You Help me Please?

    I want to start lifeCycle Es but I don`t know How to install it on my computer, Can You Help me Please?

    You can download Adobe LiveCycle ES4 trial from rhe below link:
    Learn LiveCycle | Adobe LiveCycle Developer Center
    For Documentation: LiveCycle Learn & Support

  • After reinstalling Acrobat 8 professional on new Windows 7, I occasionally get a notice that I need to Register the product but the Registration always fails; how do I resolve?

    After reinstalling Acrobat 8 professional on new Windows 7, I occasionally get a notice that I need to Register the product but the Registration always fails; how do I resolve?

    Please refer to : http://helpx.adobe.com/acrobat/kb/prompted-register-repeatedly-acrobat-8.html
    Regards,
    Anoop

  • HT2240 i already bought a quicktime pro version but lost the key some how. how can i get back that key, without buying a new one?

    i already bought a quicktime pro version but lost the key some how. how can i get back that key, without buying a new one?

    thank you Malcolm J. Rayfield for your replay. but this didn't help, because i bought the "pro" bevore that.

  • Avoiding Cartesian Products

    Hi All
    I have an SQL query that is taking a long time to run or will crash due the structure.
    I'm querying 20 fields that are sourced from 4 tables.
    Usng SQL developer, I'm given the info that the query creates 3 or 4 cartesian products.
    The basic structure is as follows, EXAMPLE ONLY;
    SELECT CUSTOMERS, PLACE, VALUE, DDATE, PHONE_NUMBER
    FROM CUSTOMERS C, PLACE P, VALUE V, DDATE D, PHONE DETAILS N
    WHERE C.ADDRESS = P.ADDRESS
    AND D.DATE BETWEEN TO_DATE ('08/06/09' , 'DD/MM/YY')
    AND TO_DATE ('10/06/09' , 'DD/MM/YY')
    OR N.PHONE_DETAILS = C.PHONE_NUMBER
    I need to rewrite this to run more quickly & may have to completely change the query structure.
    If anyone has had the same issue & a fix I'd appreciate it. Thanks

    Hi Sanjay
    here's the query
    SELECT DISTINCT DECODE(SOURCE_SYSTEM, 'S', CONCAT('SR ', SR_NUMBER), SR_NUMBER) AS S.SR_NUMBER, S.SOURCE_SYSTEM, S.SR_AREA, S.SR_SUB_AREA, S.SR_STATUS, S.SR_SUB_STATUS, S.SR_CLOSED_DATE, S.SR_PRODUCT1, S.SR_PRODUCT2,S.SR_OWNER, S.SR_SERVICE_ID, S.SR_REASON1, S.SR_REASON2, S.SR_TIO_PRIORITY, S.SR_REF_NUMBER, S.SR_REF_NUMBER_TYPE, S.SR_DATE_RECD, S.SR_CIDN, S.SR_BUS_UNIT, S.SR_MBM_SEG, S.SR_BILL_ACCT_NUMBER, S.LATEST_UPDATE, C.BEFORE_CLEANSING, C.AFTER_CLEANSING, P.DEALING, P.SERVICE_ID, P.PDATE, P.DISPUTED_AMOUNT, P.ISSUE_1, P.ISSUE_2, P.ISSUE_3
    FROM SR_MERGED_DATA S, PL2_WE_050609 P, CLEANSED_TIO_REF_IDS C, PL2_UNLOC_090609 L
    WHERE S.SR_AREA = 'Issues'
    AND (L.PSR_NUMBER = S.SR_NUMBER)
    OR (P.SERVICE_ID = S.SR_SERVICE_ID
    AND SR_DATE_RECD BETWEEN TO_DATE('01/05/09','DD/MM/YY')
    AND TO_DATE('09/06/09', 'DD/MM/YY'))
    I think you may have answered my question.
    Should I try the same syntax as you have written it instead?

  • I am creating a photo book and made the grandios mistake of using auto fill and have a zillion pics and pages i do not want I eliminated the pics but cannot delete the empty pages How can i do it  The back inside cover and back page are at the end  and I

    i have tried to create a photo book and made the mistake of trying auto fill I got a number of pages and many pics i do not want I found a way to eliminate the pics but cannot get rid of the pages unfortunately the inside back page and the back page are also there  ANY IDEAS

    At the bottom of the photo tray at the right click on the Clear Placed Photos button.  This will remove the photos from the pages but not from the book.
    Click to view full size
    OT

Maybe you are looking for