How to use LIKE in this CASE?

There are multiple values that start with "Aerospace".  All of them are going to be set to the same value.  I'm trying to write a Case Statement that will replace all of them with the new value, but i can't get the LIKE to work correctly.
  This can probably be done with REPLACE, but It's bugging me that I can't get the LIKE to work.  
I've tried a few variations, but compiler hasn't like any of them.  I'm hoping to have one line of code that will work for all of the possible choices.
What is the best way to use a LIKE or similar thing (such as CONTAINS) to set all of the fields with "Aerospace" at the beginning?
Sorry for the small font above.  I didn't see how to change it.
'New Sector Focus' = CASE sectorfocus
WHEN sectorfocus LIKE 'Aerospace%' THEN '201010 - Aerospace & Defense'
ELSE sectorfocus
END

CASE expression looks good. CASE blog: 
http://www.sqlusa.com/bestpractices/training/scripts/casefunction/
>Sorry for the small font above.  I didn't see how to change it.
Use the HTML icon to edit the html code.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • How to use to_date for this case?

    Hi,
    I bind parameters in java code.
    The param type in java is Timestamp and the data type in table is date.
    Here is the sql section printted in log:
    2004-08-01 10:00:00.0 <= table.datetime
    Why there is a ".0" after second?
    And how to use to_date to convert "2004-08-01 10:00:00.0"?
    Thanks!

    Hi,
    Here are a few possibilities
    SQL> select cast(timestamp '2004-08-01 10:00:00.0' as date) from dual;
    CAST(TIMESTAMP'2004
    2004-08-01 10:00:00
    SQL> select to_date('2004-08-01 10:00:00.0','YYYY-MM-DD HH24:MI:SS".0"') from dual;
    TO_DATE('2004-08-01
    2004-08-01 10:00:00
    SQL> select to_date(substr('2004-08-01 10:00:00.0',1,19), 'YYYY-MM-DD HH24:MI:SS') from dual;
    TO_DATE(SUBSTR('200
    2004-08-01 10:00:00

  • How to use recursive in this case?

    I have a tree showed in bweb rowser UI like this
    +- node1          
    | |
    | +- node_value1a    X 
    | +- node_value1b     
    | +- node_value1c      X
    |
    +- node2    X      
    | |
    | +- node2a      X
    | | |
    | | +- node_value2a1   X
    | | +- node_value2a2   X
    | |
    | +- node_value2b     X  
    |
    +- node3          
    |
    +- node_value3a    X 
    +- node_value3b     
    At the begining I will retrieve the user permission for each node value and show them as checked "X" , Each node have a biding userObject with property key and check status and other more(we will focus on node key name and check status only). The parent node will be calculated as checked only if all its children are checked. So every time user click one node or node value(node without children). I will re-calculate the all tree nodes status based on all node_value again and update all check box in UI page. This seems need to go from bottum up since I will do:
    . Upon the clicking of one node(can be any node) I will send a http request back to server with that node key name. I will then do the following:
    if it is uncheck requrest -> updated all its childrens as unchecked -> recalculate all its parent to update their check status to unchecked
    if it is check requrest -> updated all its children as checked -> recalculate all its parent to update their check status.(may be check or uncheck depend on other sibling node status).
    The porpuse is to update that user's access right.
    I get lost when I try coding this feature. Could sonebody here help me out ? Thanks

    So how far have you got so far?

  • How to use counter in this case

    in my selection screen i have billing doc no-vbeln.
    in my ztable i have etimes a field.
    when i enter a bill doc no and press f8, my etimes feild in ztable sets to 1.
    my requirement is if i enter a bill doc as 97600654 for first time, etimes is 1.
    for second time if i enter that same bill doc i.e 97600654 , etimes should be 2 and if third then 3 and so on.
    if a new doc is entered then etimes is again 1.
    how to code this..plz provide some code.

    Hi Rudra,
    First You need to create a Ztable(say ZTT_VBELN_COUNT) with Three fields MANDT VBELN ETIMES.
    Now in your program add code as below;
    DATA wa_vbeln_count type line of ZTT_VBELN_COUNT.
    SELECT SINGLE * FROM ZTT_VBELN_COUNT INTO CORESSPONDING FIELDS OF wa_vbeln_count where VBELN = lv_vbeln.
    IF SY-SUBRC EQ 0.
       wa_vbeln_count-etimes = wa_vbeln_count-etimes + 1.
    ELSE
       wa_vbeln_count-vbeln = lv_vbeln.
       wa_vbeln_count-etimes = 1.
    ENDIF.
    MODIFY ZTT_VBELN_COUNT FROM wa_vbeln_count.
    Regards
    Karthik D

  • How to use two split this method in my code

    How to use two split this method in my code
    if i got one string line which like this
    ("aa!bb!cc~ab!bc!cd") a
    nd want to use two split to spare ! and ~ this seal for my spare point how that output
    has come diff ?
    public static void main(String[] args) {
        String str = "aa!bb!cc~ab!bc!cd";
        String strs[]= str.split("~");
        String strE[]= str.split("!");
        int count =0;
        for(int j=0; j < strs.length; j++){
          for (int i = 0; i < strE.length; i++){   
              System.out.println(count + " " + strE);
    count++;
    the output how can it be like this
    0 aa
    0 bb
    0 cc
    1 ab
    1 bc
    1 cd

    Move your second slit inside the first loop, so you are splitting the substring, not the entire string.

  • Oracle:how to use max() function in case expression

    how to use max() function in case expression, Please explain with any example

    Hope this helps and should be self explanatory
    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col

  • HOW TO use DBDataSource in this situation?

    hi all,
      I add a Matrix on system Form(eg:BOM Form),then I want to use Matrix.LoadFromDataSource() to load data.
    the simple code is :
    SAPbobsCOM.Recordset oRecordset = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRecordset.DoQuery("select ItemCode,ItemName from OITM ");
                SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)m_SboForm.Items.Item("MatrixFormUID").Specific;
                    SAPbouiCOM.DBDataSource oDBData = m_SboForm.DataSources.DBDataSources.Item("tablename");//this dbdatasource is added before
                    oDBData.Clear();//error occur in this code:Operation is not supported in system Form
                    oRecordset.MoveFirst();
                    while (!oRecordset.EoF)
    oMatrix.LoadFromDataSource();
    how to use LoadFromDataSource() in this situation?if evaluate every control,the speed is too slow.
    thanks

    The quick way is as I wrote you - bind it to datasource (you fill it cell by cell). The code is something like:
    omatrix.Clear()
    oColumn = oColumns.Item("Column name 1")
    oColumn.DataBind.SetBound(True, "table name", "itemcode")
    oColumn = oColumns.Item("Column name 2")
    oColumn.DataBind.SetBound(True, "table name", "itemname")
    oMatrix.LoadFromDataSource();
    There isn`t necessary the while (!oRecordset.EoF) cycle

  • Javascript error on - Help - Learn how to use Numbers with this online...

    I am trying to find out more about Numbers. I am using iTunes 9.1.1 on a Vista PC. I get a Javascript error in Internet Explorer 8 when I try to access:
    Help - Learn how to use Numbers with this online resource.
    http://help.apple.com/numbers/1.0
    The link redirects to the following page:
    http://help.apple.com/iwork/safari/interface/#tan727163ed
    The above page is blank except for boxes for Keynote Help, Pages Help, Numbers help, and a blank input field that seems to do nothing. Here is the Javascript error message from Internet Explorer 8:
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
    Timestamp: Tue, 1 Jun 2010 20:55:54 UTC
    Message: This command is not supported.
    Line: 1
    Char: 41589
    Code: 0
    URI: http://help.apple.com/iwork/safari/interface/javascript.js

    Link also does not work for me in WIN 7 with IE8. However, it does work in Chrome in WIN 7. It also works in Safari on my G4. Suggest you try Chrome or it may work in another browser like FireFox or Safari in Vista.

  • How to use LIKE operator in plsql

    Hi
    I wanted to select certain rows using like operator in plsql(Input should be given by the user). I have given my experiment here .I couldn't get any result.
    As per sql syntax while using LIKE operator we should give search criteria within single quote.where as in plsql if we give within single quote its takes as string so no output is comming.what is solution ? How to use like operator in plsql?
    sql syntax
    SQL>SELECT customer_name FROM customer_header
    WHERE customer_name LIKE 'B%' ; customer_name
    Bala murali
    Babu
    Basker
    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN varchar2
         ,answer OUT type_refcur_customer) IS
         BEGIN
         OPEN answer FOR
         SELECT customer_name FROM customer_header
              WHERE customer_name LIKE ( ' v_cname ' );
    END pro_custheader_like;
    execution command
    sql>variable answer refcursor;
    sql>set serveroutput on
    sql>exec package_name.pro_custheader_like( 'R',:answer);
    plsql successfully completed
    sql>print :answer
    no row selected
    by
    balamuralikrishnan.s

    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN
    varchar2
    ,answer OUT
    type_refcur_customer) IS
    N
         OPEN answer FOR
         SELECT customer_name FROM customer_header
    WHERE customer_name LIKE ( v_cname );
    END pro_custheader_like;
    Try it without any quotes. And, let us know your feedback.
    Regards.
    Satyaki De.
    Message was edited by:
    Satyaki_De

  • How to use Compare and Swap (CAS) atomic function(Solaris specific) in C

    Hi,
    I have found cas32() atomic function in (solaris 10) </usr/include/sys/atomic.h> (and also there is another atomic.h header file in </usr/include/atomic.h> but this header file does not have any cas32() function declarations) the declaration of cas32 in <sys/atomic.h>
    is as follows
    extern uint32_t cas32(uint32_t *target, uint32_t cmp, uint32_t newval);
    extern ulong_t caslong(ulong_t *target, ulong_t cmp, ulong_t newval);
    extern uint64_t cas64(uint64_t *target, uint64_t cmp, uint64_t newval);
    extern void casptr(void target, void cmp, void newval);
    extern uint8_t cas8(uint8_t *target, uint8_t cmp, uint8_t newval);
    But the problem is when iam using these functions in c programs and compiling
    using gcc it is showing the following error.
    Undefined first referenced
    symbol in file
    cas32 /var/tmp//ccQcsnev.o
    And if i use the function other than cas32 group of instruction
    such as atomic_or_uint()
    whose declaration is extern void atomic_or_uint(uint_t *target, uint_t bits);
    in <sys/atomic.h> it is giving no error where as for CAS32 it showing as undefined symbol.Why it is giving like that we are not able to know.Is it the case that CAS32 instruction only available in Kernel mode and not available to user mode.Please inform us if anyone knows how to use cas32() instruction in the user C programs.As this is usefull for writing Nonblocking versions of stacks and Queues.Is there any way to write
    our own atomic functions?
    Rama

    You are trying to use the old kernel-only CAS functions, use the correct ones like:
    atomic_cas_32.
    DS

  • Preventing SQL injection - can't use cfqueryparam in this case

    Hello. I have a form with a checkbox next to each row.  If the user checks some boxes, then clicks the "Delete" button, I want to execute the following query, but I want to protect it from sql injection attacks:
        <cfquery datasource="#application.mainDS#">
            delete userMessages
            where messageID in (#form.messageID#)
        </cfquery>
    As written above, it works fine.  But if I try to protect this code with <cfqueryparam value="#form.messageID#" cfsqltype="cf_sql_varchar">, I get this error: "Conversion failed when converting the varchar value '7,21' to data type int" (7 and 21 are the messageID's to be deleted).  Obviously the comma prevents conversion to an integer.
    If I use cfsqltype="cf_sql_integer", then the string gets converted to a single integer (in this case 40015, which is nonsense).
    I tried passing form.messageID to a stored procedure, but I seemed to have the same problem there.  I could run the query in a loop where I just delete one row at a time, but I'd like to run just one query if I can do it safely.  Any ideas?
    Thanks.
    PK

    I agree that you should not do an SQL "DELETE" from a web page.  Instead, use "soft deletes," where you contrive for there to be a deleted_flag (boolean), and maybe deleted_by (varchar) and deleted_timestamp.  Then create an SQL "VIEW" which automagically omits the "deleted" records.
    It is also a very good idea to refer to the records using a nonsensical, made-up "moniker" instead of actual record-IDs.  You see, "if I am a nasty person and I know that there is a record #123456, then I'll bet I know the record-IDs of 123,455 other records, too."  But if you refer to the record as "QZB0E9S" and the next record-id in the list is "4Q_9RJPEM2" then it won't take me long to realize that I can't get too far, not even by brute-force.  (And if I see that the record-IDs seem to have verification tags, like "QZB0E9S:4E396", then I know that I am really scroo'd in my hacking-attempt because even if I did somehow million-monkeys my way into a valid record-ID, I've got no earthly idea how to come up with the tag.
    It pays to code defensively, like this.  And it doesn't really take more time.  Without question, always use <cfqueryparam> !!

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • Will it feasable to use Module in this case :screen shot attached

    Hi ,
    We are developing a Application which provides several facilities like Forum , Remote User , --- etc screen shot attached for this reference .
    Please tell me will it feasable to develop each of this service as a Module ??
    Please tell me shall we go for seperate Modules or for Seperate Components , what will be feasable
    Please share your experience

    Anybody please tell me if its better to go using Modules Approach , in case if they were part of the Application itself .
    Thanks.

  • How to use classloader in this way? Is it possible?

    I have one my own classlaod. So, I can do these: use the classloader to load the class, use the class's newInstance method to get instance object, then use reflection to invoke methods of the object.
    I think this is the standard way.
    However, it is not convenient. Is there a way that allows me to using the class that loaded by my own classload in "old way", i.e. just new to get object, and directly use it. For example, like this:
    ..Get classloader
    class MyClass = loadClass("MyClass");
    MyClass obj = new MyClass();
    obj.someMethod();
    If this way is possible, it is much better. In theory, it should have no problem. I think Java Web Start, etc are just doing similar like this. But, at this point, I do not know. Please share your thoughts.

    You have to distinguish between compile time, and run time features available to you.
    MyClass x = new MyClass() ; is a language construct that is available at compile time.
    Reflection is available at runtime.
    If you want a mix of both, you may have to generate code. Depending on how you like it - you can either generate source and compile it, or generate byte code directly. But since you seem to be interested more in simplifying your code, due to the relative obscurity of reflective code, your best option would be to use a code generator.
    So use your classloader to load the class, then generate and compile code to use it. (This may be even more complex, but this is how you would have to do it)

  • How tio use like operator in textitem to get the name

    Oracle forms6i
    Hai All
    I have created an form to create an hierarchy list. I that I had an Text_item how can i use like operator to get the name to select. which trigger i need to use. when i select the name i need to get his employee code and other details
    Thanks In Advance
    Srikkanth.M

    A is the head of Dept 10 and three person are under A namelyHow will you know that B, C and D are under A is there any parent child relationship between Leader and Employee code? If yes, Then you can create the relationship between blocks no need to set where_clause programatically. So, relationship can be like...
    leader_block.emp_code = emp_block.leader_code
    AND leader_blokc.dep_code = emp_block.dep_codeSo, when you will query data in LEADER block it will show employees which are under LEADER which you queried in LEADER block.
    Or if there is no relationship then how will you know that which employee under which leader?
    b 002 10 1
    c 003 10 1
    d 004 10 1
    When i enter the name of head corresponding other members in the department will need to display in the
    Tabular format Or if you want to query the records only for department relation. Then as you said you create two blocks then create create the relationship using dep_code between those blocks.
    like...
    leader.dep_code = emp_block.dep_code-Ammad

Maybe you are looking for

  • How to execute procedure in SQL Worksheet ?

    Hi, anybody know, how I can execute procedure here? I try EXEC sec_roles, EXEC security_admin.sec_roles, EXECUTE - there is a SQL statement error. When I use CALL - there is no such procedure (I have execute previleges). Although in SQLPlus EXEC work

  • Problem in ALV Grid control in selecting multiple rows.

    Dear All,          I am using ALV grid, in that first column is sel field user will select record and he press the customized button for one record it is working fine, but user unable to select multiple records without using CTRL key, and i used HOTS

  • Problem with jinitiator

    Our company uses an application that needs jinitiator 1.3.1.14 to run. I am using windows xp sp2 and i have a problem each time i try to launch this application; Explorer stops with an error message. I need to clear the temporary internet files, unin

  • Interfacing UART on Zedboard

    Hi, I want to use the the uart_tx and rx in my design. While making the pin connections in .xdc, I set set_property LOC D11 [get_ports uart_tx] set_property LOC C14 [get_ports uart_rx] (D11 and C14 are required pins, which I found from the Zedboard H

  • Editing a scanned pdf

    Hello, I have a pdf scanned from a xerox workcentre 7535. I just want to rotate it and save it in the new rotated view. I rotated it and did save as to new file name. When I open it, it is not rotated as I had saved it! Adobe Acrobat XI standard ver