Convert INT to a CHAR

Hello! I have a question about the conversion of types,

In my criteria tab I have a measure INT you need this format 20081023, first four numbers are the year, next month two and two last day. There is a formula to convert this number (always has this structure) to the: 23/10/2009?

Thank you!!

Leave your name in the column as a

Use this formula to replace the desired format

Substring (cast (as tank (a), 1, 4). » /'|| Substring (cast (a as char), 5, 2) | » /'|| Substring (cast (as tank (a), 8, 2)

If yu want to mount it as date
then mount all functionality to this day as cast (col as date)

Sorry I ddn can't see your format exactly...
Follow the below a by JOHN :-)

Published by: Kishore Guggilla on March 3, 2009 15:19

Tags: Business Intelligence

Similar Questions

  • Convert the string to char OR int to a char

    Hello

    I have a string and you need to convert it to a char

    Dim str As String = "32771.

    Or lets say

    int i = 32771;

    How to convert one of the two to char

    is this possible?

    Thanks in advance

    @spring... You can do it this way!

  • How to convert int to String

    How to convert int to String. I get the error 'cannot convert integer to int.

    Dim str As String = "abc";

    int NB = Integer.valueOf (str);

    Use Integar.parseInt (). But make sure your str contains the integer value (like str = '123') otherwise you will get the exception.

    String str = "123"; int num = Integer.parseInt(str);
    

    Concerning

    Bika

  • Convert Int to byte array.

    Hello

    I am trying to convert an int to an array of bytes and stumbled upon a solution. However, it is not appropriate for BB/J2ME.

    byte[] bytes = ByteBuffer.allocate(4).putInt(1695609641).array();
    
    for (byte b : bytes) {
       System.out.format("0x%x ", b);
    }
    

    I have converted into loop, but not an alternative to System.out.format () there is no J2ME.

    How can I convert my whole in byte array?

    Thank you.

    Hi guys, sorry for the delay in responding. Basically, I have to send my ACR122U an int on NFC. If int is more than 255 does not in a single byte then I have to represent in an array of bytes, right?

    I think RexDoug is correct also, I don't understand masking and stuff like that. It's something that I've always been conscious of good :/

    Thank you guys.

    Here's what I went with:

      public byte[] intToBytes(int value) {
    
             return new byte[] {
                        (byte) ((value >>> 24) & 0xff),
                        (byte) ((value >>> 16) & 0xff),
                        (byte) ((value >>> 8) & 0xff),
                        (byte) (value & 0xff),
                      };
        }
    

    REF: http://stackoverflow.com/questions/9587605/java-integer-to-byte-array-blackberry-j2me/9587708#958770...

  • Convert int value of sql in QString without using C++

    Hi, I'm having trouble passing an integer value in my list. I am entirely dependent on QML and would rather not touch C++ because they tend to create more problems for me sometimes.

    I need to load some data such as: Int ID, string directory in my GroupDataModel.

    It is:

    (1) I use the ID as a sort key

    AND

    (2) I want to display on my list as well.

    I found another solution that calls for the values to store them as "001, 002, 003," etc, but as I mentioned, I would like to view the information and is not sustainable.

    I wonder if maybe I can use javascript to convert this string? I tried to look for Qt btu solutions, they are all highly dependent on C++ and I do not want to touch that.

    I tried:

     function convertInt (data){return QString(%1).arg(ListItemData.CategoryID || "")}
    

    But it doesn't seem to work at all...

    I also tried ListItemData.CategoryID.toString () but it does not work as well...

    Can someone please? Thank you!

    After hours of trial and error, I finally managed to get CategoryID show.

    Instead of referring to him as ListItemData.CategoryID, I just used: ListItemData under the heading ListItemComponent.

    I also deleted the itemType function because it does not seem necessary here atm.

    Apparently it's kind of 'automatic' putting in the CategoryID in the sortingKeys and grouping.

  • How to convert an array of char byte array?

    Hello

    Someone can say, how can I convert Byte char []?

    Thank you

    What:

    data Byte [] =...

    Char [] charArr = (new String (data)) .toCharArray ();

    Rab

  • Convert int int for those tens int, int for onehundereds

    I should know this basic programming, but I have a white full spirit.

    What is the best way to take an integer like 125 and divide by an integer to put the hundreds, dozens of place and those.  For example, 125 would be:

    hundreds of int = 1

    dozens of int = 2

    int people = 5

    Thank you!

    Several ways to do so. One simple way is to convert a string and then break up in this way. Other ways involve also doing the simple math with modulo division and taking whole pieces (eg., if you want to the kth of N-integer_part ((N % 10^k)/10 ^(k-1) figure) did the trick)

    There is nothing specific BlackBerry which handles this.

  • serializeJSON is converting ints to floats

    CF10 updated 11 Win7 x 64

    I'm running on a problem that I just noticed with serializeJSON()... ints are converted to floats. Here is the code:

    < cfset r = {}

    « x » : 0,

    'y': 1

    } >

    < cfoutput > < pre > #serializeJSON (r) # < / pre > < / cfoutput >

    < cfset r.x = int (Val ("1")) >

    < cfset r.y = ceiling(100/10) >

    < cfoutput > < pre > #serializeJSON (r) # < / pre > < / cfoutput >

    Here is the result:

    {« y » : 1, « x » : 0}

    {: 10.0 'y', 'x':1.0}}

    Is this messed up or what?

    Also discovered that a simple addition operation creates a float:

    Release 3.0

    Workaround solution:

  • Convert Int to String... Incompatible Types error

    Dear members,

    I have an AM procedure that accepts two variable. Procedure is as follows:

    ' Public Sub myProcedure (param1, String userId, String)
    *{*
    * / * My logic * / *.
    *.....*
    *.....*
    *}*

    I call this procedure from the co Code. in my CO is the following:

    *.....*
    *.....*
    String param1 = "Value1";
    int userId = pageContext.getUserId ();
    * Serializable para [] = {param1, username}; *
    am.invokeMethod ("myProcedure", para);
    *......*
    *....*

    When I execute this code, I get the below error:

    INCOMPATIBLE TYPES; FOUND: INT, NEED JAVA. IO. SERIALIZABLE

    It sounds like I should pass only string variables to the serializable method. How can I convert the variable of integer type to the string variable.

    Kindly please help me to solve this problem.

    Thanks in advance.

    Best regards
    Arun D. Reddy

    Hi Arun

    Replace your line of code int userId = pageContext.getUserId ();
    with

    String UserId = "" + pageContext.getUserId ();
    Concerning
    Ravi

  • convert int to timestamp

    Hi all

    I m using Oracle 10 g. I have a front end in JAVA who call the Oracle Message_for_error table.
    This table contains the desc and timestamp as error when the error occurs.

    When I query Oracle table Message_for_error I get all the data in the column correctly.

    This table is used for the report in JAVA.
    I just want to check that the name error_timestamp in the name of the Oracle Message_for_error table column is correct in the JAVA report.

    In oracle error_timestamp of name of column has the value like * 5 June 12 10.51.45.210000000 AM *.

    and the java report displays the timestamp column * 1338873705210 *.

    It comes
    1. How can I convert * 1338873705210 * for * 5 June 12 10.51.45.210000000 AM * in oracle.
    2 * 1338873705210 * fix or maybe java does not convert correctly.


    Thanks in advance
    Saaz

    A bit like

    SELECT  TO_DATE('1970-01-01','YYYY-MM-DD') + ( TO_NUMBER ('1338873705.210') / (24 * 60 * 60) )     AS dt
      FROM  dual
    

    Concerning

    Etbin

    Edited by: Etbin on 5.6.2012 09:07
    I was told not to be fair - you definitely need a timestamp type

    SELECT  TO_TIMESTAMP('1970-01-01','YYYY-MM-DD') + NUMTODSINTERVAL(TO_NUMBER('1338873705.210') / (24 * 60 * 60), 'day') AS dt
      FROM  dual
    

    Edited by: Etbin on 5.6.2012 09:15
    Another complaint:(-je voulais vous faire savoir)

    SELECT  TO_TIMESTAMP('1970-01-01','YYYY-MM-DD') + NUMTODSINTERVAL(TO_NUMBER('1338873705.210'), 'second') dt
      FROM  dual
    
  • How to convert a negative "signed short int" in a picture of two "tank"?

    Hello

    I'm having difficulties to convert a signed short int (2 byte) in an array of two characters.

    My current test is like this:

    void ConvertShortIntToByteArray(short int value){   unsigned char byteHi = 0x00; // High Byte of result   unsigned char byteLo =0x00; // Low Byte of result
    
      unsigned char C1 = 0x00;  unsigned char C2 = 0x00;  unsigned char C3 = 0x00;  unsigned char C4 = 0x00;  short int tempValue = 0;
    
        C4 = value % 16;  tempValue = value / 16;   C3 = tempValue % 16;  tempValue /= 16;  C2 = tempValue % 16;  tempValue /= 16;  C1 = tempValue % 16;
    
      byteHi = C1 << 4;   byteHi += C2;
    
      byteLo = C3 << 4;   byteLo += C4;}
    

    It works OK for positive values (for example say that 240 = 0 x 00 F0) but negative values don't work here.

    Is there a way to convert signed short int values to an array of two bytes of an easier way?

    I know that common sense would be to go over binary like this:

    Assume value = -240:
    
    So abs(-240) = 240 = 00 F0 = 0000 0000 1111 0000
    
    One-Complement:1111 1111 0000 1111
    
    Add '1' to the One-Complement: 1111 1111 0000 1111+0000 0000 0000 0001  ------------------- 1111 1111 0001 0000
    
    Result = 1111 1111 0001 0000 = FF 10 = -240
    

    But is there an easier way that doesn't have to go to binary to achieve?

    Any help is greatly appreciated.

    Thank you and best regards,

    Bernd

    If you want to just let C do its thing:

    void ConvertShortIntToByteArray(short int value)
    {
        unsigned char byteHi = value >> 8; // High Byte of result
        unsigned char byteLo = value; // Low Byte of result
    }
    

    Or maybe a little more understandable:

    void ConvertShortIntToByteArray(short int value)
    {
        unsigned char byteHi = (value >> 8) & 0xff; // High Byte of result
        unsigned char byteLo = value & 0xff; // Low Byte of result
    }
    
  • Convert char [] array of IP address

    How can I convert an array of char [] (acquired from the user input text box) to the IP address?  It seems there being no previous discussion about this.

    Question:
    I have to use an intermediate step of dumping the content I want to check in a textbox.  Why is there not a function that works directly on a table of char []?  It seems faster for me.

    Control of intellectual property is designed as a UI control where the user can interactively enter a text to be used as an IP. The instrument limits user input to the characters 'legal' to an IP address (e.g. only numbers and periods are allowed).

    Since the instrument is distributed with the full code, you may want to consider IsIPvalid (char * string) function in the code: the function is not exposed by the instrument, however, you can check the code and finally transfer to your application if you feel it is valid for your application.

  • How to convert an int to a string

    What is the right way convert int to string?

    I try to add a new variable and just after that I change the type.

    Is this right?

    Is it possible to do without 'c' varialbe?

    Can I convert in one line?

    var c;
    
    myBtn.addEventListener(MouseEvent.CLICK, plus);
    function plus(event:MouseEvent):void {
         trace("button press");
         c=int(a.text)+int(b.text);
         rez.htmlText=c;
        trace(c);
    }
    

    intToString.png

    at least, there are 2 ways to convert an int to a string:

    1 rez.htmlText = c.toString ();   ToString is an int (uint and number) method

    2 rez.htmlText = String (c);

  • Convert uint8 hexagonal table in reverse order double, uint16, channel, etc

    I get back an array of uint8 size 4 from a buffer that happens to what follows:

    C4 e5 d7 (hexadecimal) ed

    and need to convert it so that it reads:

    d7e5edc4 (hex)

    3622170052 (decimal)

    I know it can be done in a loop using some<'s or="" something. ="" i="" can't="" remember="" all="" this="" low="" level="" stuff="" so="" help="" would="" be="" greatly="" appreciated. ="" i="" can="" rearrange="" the="" initial="" data="" array,="" but="" not="" sure="" how="" to="" convert="" to="" decimal="" number. ="" i="" assume="" a="" simple="" for="" loop="" starting="" at="" the="" end="" would="" be="" the="" easiest="" way="" to="">

    PS on this subject, where is a good place which explains all the uses of < or=""> > or ^ = etc.

    Thank you

    I happened to use this routine in the past to accomplish a task like yours:

    string to unsigned char [5];

    int number;

    String [0] = 0xc4;

    String [1] = 0xed;

    String [2] = 0xe5;

    String [3] = 0xd7;

    String [4] = 0x0;    string terminator

    number = (string) conv_dword_to_int;

    int conv_dword_to_int (unsigned char * buf)
    {
    Return ((*(buf + 3))< 24) ="">
    ((* (buf + 2))< 16) ="">
    ((*(buf + 1))< 8)="">
    ((* buf + 0));
    }

  • Convert the Sql for Oracle script

    Could someone help me convert the sql script in oracle below

    -- EXEC SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport '2005','2010','09048','IL'    
    ALTER PROCEDURE SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport    
    --DECLARE     
    @StartYY AS VARCHAR(4),    
    @EndYY AS VARCHAR(4),    
    @AgentCode AS VARCHAR(9),    
    @CompanyCode AS VARCHAR(4)    
        
    AS    
        
    DECLARE @ProfileYYYYMM AS VARCHAR(6), @SQLStr1 AS VARCHAR(8000),@SQLStr2 AS VARCHAR(8000), @SQLStr3 AS VARCHAR(8000)    
        
    SET @ProfileYYYYMM = '201005'    
        
    SET @SQLStr1 = ''    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @CompAvgCount AS  DECIMAL(38,2), @CompAvgAP AS  DECIMAL(38,2), @CompInforceAP AS DECIMAL(15,2), @CompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @CompInforceCount NUMERIC, @CompSurrenderCount NUMERIC,@ALCompInforceAP AS DECIMAL(15,2), @ALCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ALCompInforceCount NUMERIC, @ALCompSurrenderCount NUMERIC,@ILCompInforceAP AS DECIMAL(15,2), @ILCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ILCompInforceCount NUMERIC, @ILCompSurrenderCount NUMERIC '    
      
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblAgentNumber TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
      
    SET @SQLStr1 = @SQLStr1 + '  DECLARE @tblmineInForce TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblmineSurrender TABLE '   
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '     
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblAgentNumber '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT AgentName, AgentNumber, AgentRank '    
    SET @SQLStr1 = @SQLStr1 + ' FROM [SUMYOLAP0001].aetnaildb.dbo.agentprofile'+ @ProfileYYYYMM +' AgtProfile '    
    SET @SQLStr1 = @SQLStr1 + ' WHERE (LEN(agentnumber) = 5 and (left(agentnumber,1) between ''0'' and ''8'' or left(agentnumber,1) = ''A'')) '    
    SET @SQLStr1 = @SQLStr1 + ' AND (Amname not like ''%COMPANY%'' OR Amname not like ''%DIRECT%'' OR Amname not like ''%MARKETsmp%'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND agencynumber not in (''ILS'',''PLS'',''99999'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND LEFT(agencynumber,2) not in (''CD'',''DR'') AND LEFT(agencynumber,3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND RIGHT(RTRIM(agencynumber),2) not in (''CD'',''DR'') AND RIGHT(RTRIM(agencynumber),3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND companycode = ''IL'' '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineSurrender '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN ('''+ @CompanyCode +''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''S'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompSurrenderCount = COUNT(1), @CompSurrenderAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineSurrender S '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON S.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND S.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineInforce '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''' + @CompanyCode + ''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''I'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompInforceCount = COUNT(1), @CompInforceAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineInforce I '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON I.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND I.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgCount = ROUND(ISNULL(@CompSurrenderCount,0) * 100 / ( ISNULL(@CompSurrenderCount,0) + @CompInforceCount),2) '     
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgAP = ROUND(ISNULL(@CompSurrenderAP,0) * 100 / ( ISNULL(@CompSurrenderAP,0) + @CompInforceAP),2) '     
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblODSmine_Policy TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Company_Code] VARCHAR(4), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_Policy_No] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Cont_Status] VARCHAR(1), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_Premium] DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + '  [No_count] NUMERIC '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr2 = 'INSERT INTO  @tblODSmine_Policy '    
    SET @SQLStr2 = @SQLStr2 + ' SELECT DISTINCT AgtProfile.AgentName, AgtProfile.AgentNumber, '    
    SET @SQLStr2 = @SQLStr2 + ' AgtProfile.AgentRank,mine.company_code, mine.mine_policy_no, mine.cont_status, mine.Annl_Premium, 1.0 as no_count '    
    SET @SQLStr2 = @SQLStr2 + ' FROM @tblAgentNumber AgtProfile '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN [SUMYOLAP0001].aetnaildb.dbo.COMAGH COMAGH '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = COMAGH.AHAGTN '    
    SET @SQLStr2 = @SQLStr2 + ' AND (AHAMNO = ''' + @AgentCode + ''' OR AHUMNO = ''' + @AgentCode + ''' OR AHAGNO = ''' + @AgentCode + ''') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO IN (''AL'',''IL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsagent_role Role '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = Role.servicsmpagent_code '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsmine_policy mine '    
    SET @SQLStr2 = @SQLStr2 + ' ON Role.company_code = mine.company_code '    
    SET @SQLStr2 = @SQLStr2 + ' AND Role.mine_policy_no = mine.mine_policy_no '    
    SET @SQLStr2 = @SQLStr2 + ' AND mine.cont_status IN (''S'',''I'') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code IN (''AL'',''IL'') '    
    END    
    ELSE     
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' AND YEAR(mine.effective_date) BETWEEN '+ @StartYY +'  AND  '+ @EndYY +' '    
        
    SET @SQLStr3 = 'SELECT AgentName, AgentRank, AgentNumber, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END)) AS Surrrender_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''I'' THEN no_count ELSE 0 END)) AS InForce_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) AS SurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''I'' THEN Annl_premium ELSE 0 END) AS InForceAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN count(*) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END) * 100 / count(*))) END AS AgtSurrenderCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN SUM(Annl_premium) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) * 100 / SUM(Annl_premium))) END AS AgtSurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100),@CompAvgCount) AS CompAvgCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100), @CompAvgAP) AS CompAvgAP '    
    SET @SQLStr3 = @SQLStr3 + ' FROM @tblODSmine_Policy '    
    SET @SQLStr3 = @SQLStr3 + ' GROUP BY AgentName, AgentRank, AgentNumber '    
        
    EXEC (@SQLStr1 + @SQLStr2 + @SQLStr3)    
    --PRINT (@SQLStr1 + @SQLStr2 + @SQLStr3)    

    Yes.

    1. the scrap code.
    2. get the specification of the requirements of business origin.
    3. learn PL/SQL.
    4. write the PL/SQL code to meet the requirements of the company.

Maybe you are looking for