Problem with case

What is the problem with the instruction box below. I have error when running. Can someone help me please. Thank you.
SELECT CRR.ROUTE, CRR.PUBLICATION
 FROM  CIRC.CARRIER_ROUTE CRR, 
                 CIRC_RPT.VW_CARRIER_RATE_DRW VCRD 
                WHERE CRR.PUBLICATION=VCRD.METHOD_PUB 
                     AND CRR.RATE_CODE=VCRD.RATE_CODE 
                    AND (case when  CRR.ROUTE IN('40011420','40012428') then VCRD.RATE_METHOD ='SBSTD' else VCRD.RATE_METHOD ='SCSTD'  END)

Varun says:
What is the problem with the instruction box below. I have error when running. Can someone help me please. Thank you.

SELECT CRR.ROUTE, CRR.PUBLICATION
FROM  CIRC.CARRIER_ROUTE CRR,
CIRC_RPT.VW_CARRIER_RATE_DRW VCRD
WHERE CRR.PUBLICATION=VCRD.METHOD_PUB
AND CRR.RATE_CODE=VCRD.RATE_CODE
AND (case when  CRR.ROUTE IN('40011420','40012428') then VCRD.RATE_METHOD ='SBSTD' else VCRD.RATE_METHOD ='SCSTD'  END)

How can we help if we do not know the error?

BTW, I find that a bit of discipline on alignment of code allows the readability

SELECT CRR.ROUTE,
       CRR.PUBLICATION
FROM CIRC.CARRIER_ROUTE CRR,
     CIRC_RPT.VW_CARRIER_RATE_DRW VCRD
WHERE CRR.PUBLICATION=VCRD.METHOD_PUB
  AND CRR.RATE_CODE=VCRD.RATE_CODE
  AND (case when  CRR.ROUTE IN('40011420',
                               '40012428')
            then VCRD.RATE_METHOD ='SBSTD'
            else VCRD.RATE_METHOD ='SCSTD'
       END)

And now that I've lined it up, it sticks out... shouldn't the look of the CASE statement like this:

 AND (case when  CRR.ROUTE IN('40011420',
                               '40012428')
            then 'SBSTD'
            else 'SCSTD'
       END)

My personal rule is that each item in a list
-the column names in a SELECT statement
-a from the table names
-the conditions in a WHERE clause)
is listed on a separate line and aligned with the other elements in the list.

But humans read your code don't care SQL.

Tags: Database

Similar Questions

  • Problem with CASE expressions

    Using Oracle 10 g R2, plsql in SQL Developer (or TOAD). I have a question 'simple' with the criteria 'complicated' in where clause.
    So, it's something like this:

    Select the fields in a table
    where stuff like Upper(:CategoryId) | '%'
    and sub_category_id like Upper(:SubCategory). '%'
    and order_date > =: StartDate
    and order_date < =: EndDate
    and division_id =: Division

    Up to this point, the query works fine. Here is where is the problem:
    If there is a value in the following parameter field, it works very well, but it is possible that the parameter is null, then I have to test for this first, and if it is empty (or even assigned a 'false' value) then it must restore all settings. The following parameter field is titled: SKU. The reason why I do this first place is to spend several values in a field of single parameter - comma which is great as long as there is some values...

    (This works with the above)
    and INSTR (Upper(:SKU), table.sku) > 0

    And I have a similar problem with another field in the table entitled: catalogue and as: SKU, it works very well if there is at least one input value.

    What I tried (who doesn't) is therefore:
    and as table.sku (BOX WHEN: SKU = '1' AND '%')
    Of OTHER INSTR (Upper(:SKU), table.sku) > 0
    END CASE)
    Same thing with the catalog:
    and as table.catalog (BOX WHEN: catalog = '1' AND '%')
    Of OTHER INSTR (Upper(:Catalog), table.catalog) > 0

    There must be a way to make this work. I will be grateful for any suggestions that would help in my situation.

    What is

    select s.sku,
            s.std_cost_ea,
            s.unit_price,
            o.QUANTITY,
            o.order_no,
            o.order_line
    from f21.ffct_offer_product_sku s
    inner join f21.fmkt_order_detail o
           on s.sku = o.sku
           and s.company_id = o.company_id
           and s.division_id = o.division_id
           and s.offer_id = o.offer_id
           and s.offer_year = o.offer_year
    where s.category_id like Upper(:CategoryId) || '%'
    and s.sub_category_id like Upper(:SubCategory) || '%'
    and instr(Upper(nvl(:SKU,s.sku)), s.sku) > 0
    and instr(Upper(nvl(:Offer,s.offer_id), s.offer_id) > 0
    and o.order_date >= :StartDate
    and o.order_date <= :EndDate
    and s.division_id = :Division
    and s.version_no = 0
    
  • Problem with case when try to alter the query from siimple

    Hello PL/SQL gurus and Experts.

    I'm stuck with a question (can be simple), but not gettings all headsway.
    select 365/day_num_yr Anul_Fact from Date where date_dt = trunc(sysdate -1) 
    value returns is as - 1.46

    need to write it in the form of case (I have to multiply it to some other outer query), I want to store variable ina and then use the same in an outside -.
    but when use the following syntax, then it always returns 0 and not the same output returned by the query above without the scabbard.
    select (case when date_dt =trunc(sysdate -1) then 365/day_num_yr else 0 END) Anul_Fact 
    Help kindly, I appericate your time and effort in advance.

    user555994 wrote:
    Problem is that I do not get the output as 1.46, even the output is coming like the 0 only if using the query - next

    select /*date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,*/
    case when date_dt = trunc(sysdate -1) then  365/day_num_yr
    else 0
    end num_day
    from date_dim;
    

    Completely, which seems to be a question of DATA. Have you checked if the table contains data for DATE_DT = SYSDATE - 1? Can you check if the data stored do not have hours and Minutes stored?

    Although I have provided examples of data, which is the same as the data in my main table and once I used the previous solution you provided and then also gives the result as same as those mentioned by you.

    I think it's something like -

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
    case when date_dt = trunc(sysdate -1) then  366/day_num_yr where day_num_yr=(select day_num_yr from date_dim where date_dt = trunc(sysdate -1))
    else 0
    end num_day
    from date_dim;
    

    Once we get the day_num_yr then he deviding by 366/day_num_yr :(
    but he does not like throwing an error ORA-95 - missing keyword

    Yes, it does not work

    -case when date_dt = trunc (sysdate-1) then 366/day_num_yr where day_num_yr = (select day_num_yr from the date_dim where date_dt = trunc (sysdate-1))

    due to a syntax of alien.
    I don't think that you really need. I already said, with the data in your Table, you will be having only * 1 * record with a Non - zero value. Thus, simply apply a filter to extract the corresponding record SYSDATE - 1 and you should get an output which is Non-zero. If you apply a where predicate, then would not need you a CASE statement. You can directly use something like below:

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
           365 / day_num_yr num_day
      from t4
     where date_dt = trunc(sysdate - 1);
    

    Published by: Jen K, September 7, 2012 16:00

  • Problem with CASE statements

    Hi all

    I have a calculation in a report of Discoverer Desktop with 29 instructions BOX and still 2 case statements more to add. The problem is that my report freezes and fails to run due to the excessive number of case statements. I need to put the 31 statemnts cases in the report, how do I do this? Is there another way to do it without causing the report to freeze?

    Below is part of my instructions box just to show you what I'm doing:

    CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
    CASES WHERE Ex = "PP" AND result IN (40,35,30,25) THEN NULL OTHERWISE
    CASE WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
    -CASE WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
    -CASE WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...

    The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END END END END...

    Help, please. Thank you.

    Hello
    You have reached the limit of characters in a calculation.

    Try to set into a single statement as follows:

    CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
    WHEN Ex = "PP" AND as a result (40,35,30,25) THEN NULL OTHERWISE
    WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
    WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
    WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...

    The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END

    Another option is to combine all the statements of NULL in a series of gold options like this:

    BOX WHEN
    (Ex = 'MM' AND the result in (', am')) OR
    (Ex = "PP" AND result IN (40,35,30,25)) OR
    (Ex = he's ' AND translated BY (' a ',' B', 'C', ')) OR
    (Ex = 'IO' AND as a result ('Distinction', "according to merit")) OR
    (Ex IN ("ZZ", "WW", "SS", "KK") AND result IN ('PASS', 'P')) THEN ANOTHER NULL...

    Best wishes
    Michael

  • WiFi problem with case

    I have an iPhone 5. And when I on my phone in case it is the wifi does not work its cannot search any wifi device but without breaking its impeccable operation until this problem of good trying to tell me

    concerning

    I don't remember hearing any case at the origin of this problem, but it seems that you have isolated it to the case yourself. This kind of case is this? I suggest at this stage that you get another case.

  • Problem with Case statement

    I try to use a case statement in a report of the Apex, but I get an error message.

    It comes to my sql

    CASE WHEN EXISTS (select stg.extkey, distsubtrpgrpid

    of udm_da da

    udm_di di

    udm_distsubtrpgrp stg

    where di.disttransgrpid = stg.disttransgrpid

    and da.daid = di.daid

    and da.suid = su.suid)

    THEN

    Select stg.extkey

    of udm_da da.

    udm_di di,

    udm_distsubtrpgrp stg

    where di.disttransgrpid = stg.disttransgrpid

    and da.daid = di.daid

    and da.suid = ' | Qul SUID. '

    Stg.extkey group, distsubtrpgrpid

    Union

    Select stg.extkey

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = ' | NVL (su.distsubtrpgrpid-1). '

    order by 1

    WHEN su.distsubtrpgrpid IS NOT NULL

    THEN

    Select stg.extkey, distsubtrpgrpid

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = ' | NVL (su.distsubtrpgrpid-1). '

    order by 1

    ON THE OTHER

    NULL VALUE

    END DISTSUBTRPGRP_1

    Any help appreciated

    Gus

    GusC wrote:

    Yes you are right.

    My sql must be

    CASE WHEN su.distsubtrpgrpid IS NOT NULL

    THEN

    Select stg.extkey, distsubtrpgrpid

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = su.distsubtrpgrpid

    ON THE OTHER

    NULL VALUE

    END DISTSUBTRPGRP_1

    But the report won't save

    Gus

    No, your SQL is not that.

    The select statement that you put online here, aside from being not not in brackets, is the selection of two values, but you can provide two values for the result column.

    Without knowing who the SQL statement, we can highlight only the obvious questions.

  • Dead pixel blackBerry Smartphones and the problem with the case of my BlackBerry 9780

    Hello world

    Recently, I bought a BlackBerry 9780 by Vodafone Spain (23 December) and I found a few problems.

    One of them is the presence of a dead pixel in the upper right and the feeling of the case a little weak in the left side that, when you touch it you can feel it creaks a bit.

    I would like to know if the warranty of BlackBerry or Vodafone Spain will cover this problem or if some of the new users of this model of BlackBerry noticied some of these problems and knows how to solve this problem.

    Sorry if they have problems with spelling. My usual language is Spanish .

    Thank you very much.

    A dead pixel is a hardware fault, and there is no miracle for her.

    Check if you can get a replacement.

  • I have problem with value NULL when the use CASE statement please help this question

    I have problem with value NULL when the use CASE statement please help this question


    Table: digital_val

    SNO cl C2

    1 San1 11

    2 22 San2

    Actual result: expected to A         B

    A            B                                                                           11        22

    11 NULL

    22 NULL



    query:

    Select case when c1 = "san1" then c2,.

    case If c1 = "san2" then c2 B

    of digital_val

    I'm more curious why, when you select 2 rows, you expect a result of row?

    WITH digital_val

    AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)

    UNION ALL

    2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)

    SELECT CASE WHEN c1 is "San1" THEN END AS A c2.

    CASE WHEN c1 = "San2" THEN END AS B c2

    OF digital_val;

    With no other input, if you select 2 rows, you get 2 rows.  One of the other solutions use a max function, but is this really what you want, does not specify?

  • I've updated to 2015.2 in September and started having problems with freezing while working on the photos. I upgraded my memory from 4 GB to 8 GB and it has disappeared (in most cases); However, I always feel a lot of questions of export of JPEGs (gel) bu

    I've updated to 2015.2 in September and started having problems with freezing while working on the photos. I upgraded my memory from 4 GB to 8 GB and it has disappeared (in most cases); However, I always feel a lot of questions of export of JPEGs (gel) but not tif files? Very frustrating. Tried to install the new updates but my creative cloud is just a blank page?

    Hello

    I think you are referring to the white empty window of CC desktop application.

    Please refer to the threads below where this issue has been addressed:

    Creative cloud is empty window why?

    Cloud Desktop App is empty?

    New application Cloud Creative unusable: it is empty!

    Re: Empty opening creative cloud app

    Kind regards

    Sheena

  • There is a problem with Adobe Acrobat/Reader. If this is the case, please exit and try again. (0:104)

    There is a problem with Adobe Acrobat/Reader. If this is the case, please exit and try again. (0:104)

    I get this message when I try to open a PDF from a Web page link. When I open the task on the Applications tab Manager, I don't see that adobe Acrobat/Reader listed at all.

    How can I solve this problem?

    I can answer my own question.

    After typing "patch" and read a few threads, I found out how to fix it.

    http://forums.Adobe.com/message/4541936#4541936

  • Page of Yahoo mail that says 'there a screen resolution problem". A in case of problems with all stakeholders, even all the browsers. The question is Firefox!

    I have the latest version of Yahoo mail. When I click on the link "mail" of my Yahoo homepage, he directs me to a page that reads, "There is a problem of screen resolution". In the body of this page, it explains how to fix the problem. BUT, I don't have a problem with the resolution - the screen resolution should be 1024 x 600 or greater and IT IS! This only happens with YOUR browser. I have Chrome and IE, neither of which is a problem. I worked with a representative of the yahoo mail support and he explains that it IS a problem with Firefox and for raise you awareness and fix the problem - I use a Vista operating system on a computer and Windows 7 on my other computer, which has the same problem, so we KNOW for sure, it's a Firefox issue.

    I don't think that the effects of this question all those who use Firefox because I'm able to visit Yahoo Mail without any problems. I would say that to reset the zoom of the page on the page, this issue occurs on. You can do these steps go to view > Zoom > reset or press (Ctrl + 0 (zero).

  • I have intermittent problems with iphoto importing from iphone since 0sx 10.11.6. Update

    I have intermittent problems with iphoto importing from iphone since 0sx 10.11.6. -Update

    1 iphoto sees not iphone - restart

    2 iphoto sees iphone but says "no pictures" - restart

    3 Iphoto sees phone and photos and I click Import all or import selected - then I have problem of file format and nothing is imported

    NOTE: I have similar problems with image capture - sometimes you can see the phone and photos, and sometimes is not

    I have an imac 2015 - execution of yosemite

    Help my new iphone because 7 is coming today and I am terrified of the transfer.

    Not sure, but in any case iPhoto is a dead - it would be really smart to learn pictures (a totally new and different program with a learning curve and different workflows)

    With the help of pictures with my new iPhone 7 and iCloud photo library all works well without any problem - nothing different photos with my iPhone except the news and the best quality Photos 5

    LN

  • macOS Sierra problems with screen sharing

    Hello

    After update to Sierra in two of my Macs, I can´t use the screen sharing. I used to use my second computer using screen sharing, but now, whenever I connect I see the split screen but active areas for use on as sleep, restart and turn off keep its original position. This means that if I like the closing down of the remote computer, I need to press just left... really strange sleep.

    I'm trying to connect to remote VNC Android and the appearance of the screen split also and with the same problem.

    Anyone has the same problem or an idea how to fix?
    Thanks in advance!

    Solved!
    Omission of base: after the descent of the Sierra update on both computers, forgot I manually start the.app after the update to the same date (a few minutes before). This cause the problem.
    I launch the.app server run OK and no problem with screen sharing.
    Maybe not to repeat this mistake, but just in case it's useful, I leave my explanation.

    See you soon,.

  • Problems with scrolling after update

    IM currently using the BlueJ ide and after updating to the new system / update (macOS Sierra) there is significant lag / jitter when scrolling. This problem only occurs when you use the scrolling with two fingers with the touch pad. When I use a mouse / or click the scroll bar on the side, it seems to go well. Not sure if there is a problem with BlueJ or the new OS. Would be very interested for some suggestions on how to fix this very annoying problem. (Using a Macbook pro 13, 2015).

    Thanks a lot to all the answers

    The obvious question would be if you see the problem of scrolling in Mac OS standard applications such as Mail, Notes and Safari.

    If this isn't the case, it is likely BlueJ.

  • Problem with iPhone 6 more 'no service '.

    update my iPhone iOS IOS 10 9.3.5 6 more. not always shows 'no service' him! No phone call, no data after only came out of my toolbox.and signal is after about 10 to 20 minutes. But never happened before with iOS 9.3.4 and earlier versions. Has happened with 9.3.5 iOS and iOS 10. And now another problem with my phone after updating to iOS 10. The above icons on my phone are all disappear. Something like Bluetooth battery icon battery percentage and cellular clock are all disappear.

    Have you ever tried the General troubleshooting steps?

    1 force restart the phone now sleep and home for 10 seconds, button until the Apple logo comes back again. You won't lose data.

    2. in case that does not work, set back to factory settings, without using the last backup. Test the phone. If it works, restore the backup.

    Use iTunes to restore your device to factory settings - Support Apple iOS

    3. If the factory reset does not help, get the phone checked by Apple:

    Launch a service request

    Find an Apple authorized service provider

    Make an appointment at the Apple Store

Maybe you are looking for

  • Firefox 22.0 can run on Mac 10.5.8 (Leopard) since it has code i386?

    Firefox 22.0 has 1386 code (such as x86_64), and the only difference in Info.plist is basically being instead of 10.5 10.6 as in Firefox 16.0.2 LSMinimumSystemVersion. So why can't Firefox 22.0 running Leopard (10.5.8) with simple changes to the Vers

  • waiting for AT &amp; T, the activation call wifi

    I try to activate AT & T wifi calling all in overseas and got everything and he gave me the message about the wifi calls must be activated in a few minutes, but its been over an hour and it still shows as the wifi calls are not enabled. I tried to ac

  • Satellite L350D - crash after update BIOS?

    Hey all. Put windows XP on my Satellite L350D, worked well, has all the drivers etc. and works perfectly. Returned on the toshiba site and saw there is an update of the BIOS for it, then downloaded and says to install. To halfway through she turned o

  • X 220 changed for Windows 7 login screen

    My laptop X 220 happened two days ago and the (before going on the desktop) login screen has changed black background with the word THINK of the plain background of Windows 7. Within two days I got my computer, I was in love with the black background

  • half way throu a vido the pictuer go s White

    I get video from the bottom of the friends I have load go to my Media Player to watch and halfway to you the image goes out I can here the sound but no picture