Min and NVL with subquery

Hello,
Below is my query
                 select  nvl( min(csp.coeficient_value),  (select csp1.coeficient_value
                                                             from csp csp1
                                                            where csp1.rule_code = 'A55' )) coeffient_value
                   from adr,
                        sec,
                        rpr,
                        csp
                  where adr.adr_id = sec.adr_id
                    and sec.account_id = 663799
                    and adr.pcode between rpr.start_pcode and rpr.end_pcode
                    and rpr.rule_code = csp.rule_code
                    and sysdate between csp.start_date and csp.end_date when i run this query it is giving me an error "ORA-00933: SQL command not properly ended"
Can anyone help me with this?
As i don't want to hardcode the value of rule 'A55' and want to retrieve from database.
Thanks for your help.
Message was edited by:
AB

By using below query my problem is resolved.
select nvl(coeffient_value, (select csp1.coeficient_value
                                                             from csp csp1
                                                            where csp1.rule_code = 'A55' ))
from (
select  min(csp.coeficient_value)  coeffient_value
                   from adr,
                        sec,
                        rpr,
                        csp
                  where adr.adr_id = sec.adr_id
                    and sec.account_id = 663799
                    and adr.pcode between rpr.start_pcode and rpr.end_pcode
                    and rpr.rule_code = csp.rule_code
                    and sysdate between csp.start_date and csp.end_date )Thanks to all for helping me.

Similar Messages

  • Max, Min and Count with Group By

    Hello,
    i want the max, min and count of a table, which is grouped by a column
    I need a combination of these two selects:
    select
         max(COUNTRY_S) MAXVALUE,
         min(COUNTRY_S) MINVALUE
    from
         tab_Country
    select
         count(*)
    from
         (select COUNTRY_TXT from tab_Country group by COUNTRY_TXT) ;
    The result should be one row with the max and min value of the table and with the count of the grouped by table, not the max and min of each group! - i hope you understand my question?
    Is this possible in one SQL-select?
    Thank you very much
    Best regards
    Heidi

    Hi, Heidi,
    HeidiWeber wrote:
    Hello,
    i want the max, min and count of a table, which is grouped by a column
    I need a combination of these two selects:
    select 
         max(COUNTRY_S) MAXVALUE, 
         min(COUNTRY_S) MINVALUE 
    from 
         tab_Country 
    select 
         count(*) 
    from 
         (select COUNTRY_TXT from tab_Country group by COUNTRY_TXT) ; 
    The result should be one row with the max and min value of the table and with the count of the grouped by table, not the max and min of each group! - i hope you understand my question?
    Is this possible in one SQL-select?
    Thank you very much
    Best regards
    Heidi
    It's not clear what you want.  Perhaps
    SELECT  MAX (country_s)               AS max_country_s
    ,       MIN (country_s)               AS min_country_s
    ,       COUNT (DISTINCT country_txt)  AS count_country_txt
    FROM    tab_country
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Avg, Min and Max with a serious twist.....ASO

    Hi,
    I need to calc the Avg, Min and Max on Revenue. That's simple. However Every row of data the revenue falls into a bucket/range. For example revenue is in buckets '0 to 50' or '51 to 100' or '101 to 150' lets say. As I load data I load a '1' into a 'Count' measure depending on which bucket that row of data falls into. So I can get a total count for each bucket. So '0 to 50' might have a Count of 3. '51 to 100' might also have 3 and '101 to 150' has a 2. So my range count looks like:
    0 to 50 - 3
    51 to 100 - 3
    101 to 150 -2
    The trick is they only want the Avg, Min and Max on the rows that makeup the highest 'Count'. In this case that's 3. Problem is there are two ranges that meet this criteria. When that happens they want the Min, Max and Avg of the rows that make up the '51 to 100' bucket since it's the highest range.
    I can easily get the '3' by using the Max formula. So I know what the highest bucket is. Problem is I can't figure out for the life of me, how to pass only those rows that make up the '51 to 100' bucket into the Avg, Min and Max function.....
    I'm stumped and in dire need of something here. I have a spreadsheet that explains the problem better. If somehow I can get a flag on those rows I can easily Avg, Min and Max it. I just can't seem to figure out how to get a flag on only those rows of data.
    I'm willing to share my mocked up example and spreadsheet and .otl and sample data etc....
    Please help :)

    Why does this verify with Min?
    Min ( Filter ( CROSSJOIN ( Descendants ( [Service].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Segment].CurrentMember),
    Filter ( CROSSJOIN ( Leaves ( [Ranges].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Customer Type].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Zip Code].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Disposal Option].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Tickets].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Yardages].CurrentMember),
    Filter ( Descendants ( [Contract Year].CurrentMember),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) ) , [FHRev] )
    And when I just change to Tail and put a 1 at the end it fails?
    Tail ( Filter ( CROSSJOIN ( Descendants ( [Service].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Segment].CurrentMember),
    Filter ( CROSSJOIN ( Leaves ( [Ranges].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Customer Type].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Zip Code].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Disposal Option].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Tickets].CurrentMember),
    Filter ( CROSSJOIN ( Descendants ( [Yardages].CurrentMember),
    Filter ( Descendants ( [Contract Year].CurrentMember),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) )),
    [High Range Max] = ( [High Range Max] , [All FHRev Ranges] ) ) , 1 )

  • VERY Slow on startup (10 mins) and now with programs?? help!!

    Just wanted to know if any one knew some easy fixes, or is my hard drive or board on the way out??...its only 1.5 years old, so its should not have these problems...my warranty was just for one year. I love MAC but this is the second computer that seems to just expire around the two year mark, its a bit upsetting:-((((
    matthew
    IMAC G5 isight   Mac OS X (10.4.9)  

    No easy fixes, but try resetting your PRAM and your SMU and see if that speed things up. How much RAM do you have? IMHO, you need at least 1 GB to function with any kind of speed.
    Miriam

  • I have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    Do you possibly mean the contacts have been merged?
    If so, where are each of you syncing contacts?  A supported application on the computer? iCloud or another cloud service? An Exchange server?
    WIthout details, it's difficult to offer specific resolutions.

  • I have just purchased a lightning to 30 pin adaptor to use on an iPad mini and a gen5 iPod touch both devices are running iOS 8.1.3 and come up with The error message "this accessory is not supported by this device "

    I have just purchased a lightning to 30 pin adaptor to use on an iPad mini and a gen5 iPod touch both devices are running iOS 8.1.3 and come up with The error message "this accessory is not supported by this device "
    THis is means they are not charging on a 30 pin cable and the touch won't work in my Apple iPod dock - no audio out or charge. Have re powered both devices to no avail am wondering if the iOS version is the problem
    Help!

    If it is a lightning to 30 pin adaptor, and you have a 7th Generation Nano it has to fit the Nano.
    This is lightning to 30 pin adapter: http://www.bestbuy.com/site/Apple%26%23174%3B---Lightning-to-30-Pin-Adapter/6651 936.p?id=1218803450821&skuId=6651936#tab=overview
    Is this what you bought?
    You need to contact Sony and see if they model you have is compatible with the docking adapter. It may not be.

  • My itunes 11 Home sharing is not working with my windows 7 PC and iPad it shows up on iPad and when I go to share the music app does loading for 3 mins and crashes I am using a virgin super hub router please please please help

    My itunes 11 Home sharing is not working with my windows 7 PC and iPad it shows up on iPad and when I go to share the music app does loading for 3 mins and crashes I am using a virgin super hub router please please please help

    My itunes 11 Home sharing is not working with my windows 7 PC and iPad it shows up on iPad and when I go to share the music app does loading for 3 mins and crashes I am using a virgin super hub router please please please help

  • I have an IPad mini and I changed the Apple ID and the password almost one year ago and, for a while, a message asking me to sign in to iCloud pops- up constantly. My iCloud account is registered with an old email and password. I do not remember the

    I have an IPad mini and I changed the Apple ID and the password almost one year ago and, for a while, a message asking me to sign in to ICloud pops- up constantly. My ICloud account is registered with an old email address and password. I do not remember the password to my ICloud account, and ID address that my ICloud account is registered under is an old email adress which is deleted right now (the old mail account is deleted). I don’t have a rescue email adress and I don’t know the answers to the security questions, so I have no way of changing the ICloud password. A message asking me to sign in to ICloud pops up constantly, but I always just hit cancel. However, now I am unable to access Find My IPad. How do I get my ICloud account changed and registered to be under my current Apple ID (email) and password? It is possible to set the device as New Ipad?

    Welcome to the Apple community.
    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact Apple ID Support, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • TS3367 If I have an IPad mini and my wife has an IPad, can I connect to her IPad with FaceTime from my IPad Mini? Are multiple Apple ID's required? One for each device/person?

    If I have an IPad mini and my wife has an IPad, can I connect to her IPad with FaceTime from my IPad Mini? Are multiple Apple ID's required? One for each device/person?

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    For non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
     Cheers, Tom

  • HT2998 Hi, I try to conect Mac Mini from 2009 with my HD Tv Samsung F 6400 . With Mini Dvi conection and adapter to HDMI input in TV I got picture but not sound! I have analog cable from the phones out from mac but imposible to conect to TV? Can you HLP

    Hi, I try to conect Mac Mini from 2009 with my HD Tv Samsung F 6400 . With Mini Dvi conection and adapter to HDMI input in TV I got picture but not sound! I have analog cable from the phones out from mac but imposible to conect to TV? Can you HLP?

    You really need a newer Mac Mini with a true HDMI output, because that Mac Mini's DVI output does not support Audio.
    You might try a 3.5mm to RCA adapter
    from the Mac Mini's headphone jack to the TV's audio input,
    but that would require being able to select the Audio input in the TVs menu while using it's HDMI input.
    Optionally you could also use an external 2.1 Speaker System or patch the audio from the Mac Mini to your home stereo system to enhance that older Mac Mini's audio.

  • I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161.  Any ideas?

    I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161.  Any ideas?

    The latest Apple driver support begins with the MP 171.
    Here is Ricoh's official driver download page specifically for the Afico MP 161. Note that new drivers for this device were released on Aug 2, and include Lion and Mountain Lion.
    Hopefully, this will solve your device issues.

  • I am trying to switch laptops with my mom, and successfully wiped mine and restored it, but now her password won't allow her into my computer, even though it says it's her account. Is there any way to bypass the password screen?

    I am trying to switch laptops with my mom, and successfully wiped mine and restored it, but now the password that she used on her computer isn't working on this computer. Is there any logical reason why the two passwords would be different, if I restored her information from a Time Machine backup? Aditionally, Is there a way to bypass the password page on startup to make a password that my mom knows?

    If Disk Warrior does not work you can try the following steps (but they may not work if the disk has a hardware error).
    Get the disk (DVD or CD) that came with the system (since you have it listed as 10.6.8).  If it is 10.7 or 10.8 use the Recovery partition to boot from or the USB installer if you have that option.
    Insert the disk then power down
    HOLDING the C key, power up to boot from the disc.
    Get to Disk Utility
    If Disk Utility will now show your hard drive, use DU to REPAIR the disk.
    When it completes the Repair process successfully as indicated in DU, do a shut down.  If Repair is not successful then an different course of action is indicated below.
    Then HOLDING THE APPLE (or Command key depending on your keyboard) KEY AND THE OPTION KEY AND THE LETTER P AND R KEYS, continue hiolding them until you hear the chime tone for the THIRD time then release all four keys.
    If REPAIR is not successful, use the Install disc as a boot and REINSTALL THE OS X OPERATING SYSTEM  DO NOT ERASE THE DISK OR VOLUME FIRST.  REPEAT DO NOT erase the disk or volume before trying to reinstall the OS X operating system.  After re-installing the OS do a software update.  Note that ERASING the disk is NOT required to do an OS re-install.  This allows your existing data and application files to remain.
    If that fails then you are down to the "bitter end" of erasing the volume and reinstalling the OS and then all the other software.
    If erasing the Volume fails then your last hope is to completely erase the entire hard drive, repartion the disk  and try a re-install.
    If that fasils then you may have a defective hard disk.

  • I want to hook up a mac mini and us my tv as a monitor. how can I use airplay from my phone on the mac mini like i can with an apple tv (without having to buy an apple tv!). the airplay capabilities i want to use are mirroring and streaming from my iphone

    i want to hook up a mac mini and us my tv as a monitor. how can I use airplay from my phone on the mac mini like i can with an apple tv (without having to buy an apple tv!). the airplay capabilities i want to use are mirroring and streaming from my iphone!

    Download AirPlayer for Mac - Transforms your Mac into an AirPlay-compatible display. MacUpdate.com

  • HT1349 I ordered iCloud with iTunes on my PC; now I have an iPad mini and want to sync the music

    First I added iCloud with iTunes on my PC because I wanted to save the music I had purchases; I had Vista; that PC died and am now on Windows 7; Then I purchased an iPad mini and today I tried to set up both so I could sync the music purchased on iPad mini and PC previously.
    However on the PC when I enter iCloud it does not have iTunes available; so I'm stuck and don't know where or how to get the music to sync between the two. It keeps asking for a serial number on the Apple product for the PC but that doesn't apply.
    As a newbee I'm grateful for any answers or clues where to go. Thanks, Janet

    Unless you backed up your iTunes library from the old computer and then copied it to the new computer, your iTunes library is gone now and you have to start all over again.
    I'm not sure what you mean about when you entered iCloud, iTunes isn't available. You will need to explain that a little better. iCloud allows you to download the music again to your computer or to your iPad as long as you use the same Apple ID that you used to purchase the music or any other iTunes content.
    Since you have a new computer and no longer have the iTunes library - or so it seems from what you are saying - you need to make the new computer your syncing computer. You might want to take a look at both of these user tips to see how you can do that.
    https://discussions.apple.com/docs/DOC-3141
    https://discussions.apple.com/docs/DOC-3991

  • My friend bought an ipad mini and gave me his old iPad. how can i re-register the iPad in my name so that i can sync it with my macbook air?

    My friend bought an ipad mini and gave me his old iPad. how can i re-register the iPad in my name so that i can sync it with my macbook air?

    Setup as new
    Settings>General>Reset>Erase all content and settings

Maybe you are looking for

  • How to identify the field value has been changed to new value?

    Hi, I am adding a custom field through CI include for 171 info type. But I need to identify that whenever user enters into change mode and changes the value(Custom field) then I have to populate an error message(i.e Manitain date type in 41.). I know

  • Reminders keep coming back no way to delete.

    I updated to IOS5 last week. I put in two reminders in the new notification center. These are both location asked (Call Dentist when leaving home) (install software on Doug's computer when arriving home) They are not my reminder list (there are none

  • Does server have domain functionality?

    Will 10.7 server provide windows clients with domain login features?  The help manual makes it sounds like it can, but doesn't actuallly say it.  It also isn't accurate in describing how to verify.  Can someone verify if it will or won't support this

  • Link to Two js files same page

    I need to link to two js files on the same page. How do I get them to both work? one is for a togler.js and the othe for a menu .js <script src="../js/togler.js" type="text/javascript"></script> <script type="text/javascript" src="../js/p7exp.js"></s

  • How to Print Auto GR Slip, TR, TO

    Hi All, when I post the GR via MIGO, the GR Slip and TR will be printed automatically. Then, if I the TO via LT12, the TO is printed automatically. I would like to know why these docs are printed automatically? Is there a way for us to choose if we w