Count to 100

I have a stored procedure that currently works fine.  The procedure counts to 25 and returns a number when a "1" is present in that place value.  My problem is that I need to change the procedure to count to 100 and return a number when
a "1" is present in that place value, with a "1" in the 100 place it should return "00".
Here is my current procedure:
DECLARE 
@alias char(6),
@wfrs varchar(256),
@numbers varchar(300),
            @list varchar(300),
            @i int
SET @i = 0
SET @numbers = ''
SET @list = '' 
SET @wfrs = 1111000000000001110000001
SET @alias = 'WP'
WHILE(@i <= 25) BEGIN
            IF(SUBSTRING(@wfrs,@i,1) = 1) BEGIN
                  IF(@i < 10) BEGIN
                        SET @numbers  = '0' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                   END ELSE BEGIN
                        SET @numbers  = '' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                  END
            END 
            SET @i = @i + 1
      END
      PRINT @list
And this is the return from @list:  WP    -01 WP    -02 WP    -03 WP    -04 WP    -16 WP    -17 WP    -18 WP    -25
When I change to 100 characters:
DECLARE 
@alias char(6),
@wfrs varchar(256),
@numbers varchar(300),
            @list varchar(300),
            @i int
SET @i = 0
SET @numbers = ''
SET @list = '' 
SET @wfrs = 1111000000000001110000000000000000010000000000000000000000111000000000000000000000000000000001110001
SET @alias = 'WP'
WHILE(@i <= 100) BEGIN
            IF(SUBSTRING(@wfrs,@i,1) = 1) BEGIN
                  IF(@i < 10) BEGIN
                        SET @numbers  = '0' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                   END ELSE BEGIN
                        SET @numbers  = '' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                  END
            END 
            SET @i = @i + 1
      END
      PRINT @list
I get this error: 
The number '1111000000000001110000000000000000010000000000000000000000111000000000000000000000000000000001110001' is out of the range for numeric representation (maximum precision 38).
Where is the "Maximum Precision" classified?

Below should work:-
Since wrfs is a varchar, it should be set between ''
DECLARE 
@alias char(6),
@wfrs varchar(256),
@numbers varchar(300),
            @list varchar(max),
            @i int
SET @i = 0
SET @numbers = ''
SET @list = '' 
SET @wfrs = '1111000000000001110000000000000000010000000000000000000000111000000000000000000000000000000001110001'
SET @alias = 'WP'
WHILE(@i <= 100) BEGIN
            IF(SUBSTRING(@wfrs,@i,1) = 1) BEGIN
                  IF(@i < 10) BEGIN
                        SET @numbers  = '0' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                   END ELSE BEGIN
                        SET @numbers  = '' + LTRIM(STR(@i))
                        SET @list  = @list + @alias + '-' + @numbers + ' '
                  END
            END 
            SET @i = @i + 1
      END
      PRINT @list
Please mark the answer as helpful if i have answered your query. Thanks and Regards, Kartar Rana

Similar Messages

  • Preloader not counting to 100 pct

    Hi,
    Another question for this site:
    http://www.mattsrotisseriesite.fatcow.com
    My preloader works as intended except my percentage of the
    "loading completed number" does not count to 100 % but to 25 % at
    the time it goes to the main time line.
    I just wanted the main movie to load 25 frames before
    starting.
    Somehow these 25 frames need to equal 100%
    Anybody?
    Thanks on beforehand,
    ggaarde

    Forgot to inclued my code. Here it is
    ggaarde

  • Item "Start/stop table":  Counts towards 100 item per page limit?

    One of my form pages has many items and aligning them all just right is quite a chore.
    I found myself using lots of those handy "start/stop table" items instead of fighting with the colspan, rowspan, New Line/New Field attributes.
    Question: Do these "start/stop table" items count toward the 100 item per page limit?
    [I hope the answer is No]
    Thanks

    Vikas - The answer is no. It's only when the counter gets incremented, e.g., between p_t01 and p_t02, ... You can see that the stop-and-start (not star/stop) items do not generate html items with such a sequence component.
    Scott

  • OBIEE 11G Count problem

    Hi Gurus,
    I want to convert to below condition to obiee.
    Database Condition like below:
    ZEROIFNULL(CAST((CAST(COUNT(CASE WHEN END_output<=.033 and END_output>='-.117' THEN END_output END) AS FLOAT)/
    CAST(NULLIFZERO (COUNT(In_PUT)) AS FLOAT)) AS DECIMAL(10,1)))*100 AS Real_Time
    In Database output is = 48
    I have converted to OBIEE like below.
    IFNULL( CAST ( COUNT(CASE WHEN "- Order Fact"."END_output" <= .033 and "- Order Fact"."END_output" >='-.117' THEN "- Order Fact"."END_output" END) AS FLOAT ), 0) / CAST(IFNULL (COUNT("- Sales Fact"."In_PUT"),0) AS FLOAT ) *100.0
    In OBIEE output is = 45
    Note: I am getting two or three count difference in OBIEE.
    I guess the problems is Decimal, how to apply decimal in obiee like (DECIMAL(10,1)))..
    Please help on this.
    Note: I have tired several methods like below but no luck still am facing problem.
    (COUNT(CASE WHEN (END_output*1.00)<=.033 and (END_output*1.00)>='-.117' THEN (END_output*1.00) END)/
    COUNT(In_PUT))*100.0
    Please help me on this ...
    Thanks

    Hi Actually,
    we have the same issue but not with case statement, the value changes bec of missing decimals, so try to put the data format to show decimals and run in a table view to see the missing decimals so u find the exact and with the associate dimension.
    Just have a work around on it.

  • Java is 100% pure object oriented language or not?

    PLS help me...?
    I am get confussed.
    Java is 100% pure object oriented language or not?

    the only full OO programming language on thisplanet
    is SmallTalk.On your planet maybe. On mine, at least Eiffel
    also exists, probably more unknown others too. Some
    count Ruby, but I never looked at it.Ruby is pure OO too, FYI.
    the only full OO programming language on thisplanet
    is SmallTalk.Care to explain it in some more detail? What
    exactly is 100% OO, b.t.w.?No, I don't careWow, what an incredibly unhelpful response.
    In essence, 100% OO implies that every type within the language is an object. Since Java has primitive types like int, boolean, float etc, it cannot count as 100% OO.

  • New HDD Load / Unload Cycle Count increasing extremely fast !

    Hi all
    I just upgrade my Pavilion dv5 HDD. The new model is Hitachi Travelstar 7K500 (HTS725050A9A364). However, I found my new HDD's Load / Unload Cycle Count increasing extremely fast!
    Until now the number of Load / Unload Cycle is 12,127. However, the new HDD only power on 137hours. (About 1 week of my use.)  The data below is my new HDD's SMART data (by EVEREST 5.50):
    ID   
    01    Raw Read Error Rate    62    100    100    0   
    02    Throughput Performance    40    100    100    0   
    03    Spinup Time    33    159    159    2  
    04    Start/Stop Count    0    100    100    14   
    05    Reallocated Sector Count    5    100    100    0  
    07    Seek Error Rate    67    100    100    0  
    08    Seek Time Performance    40    100    100    0  
    09    Power-On Time Count    0    100    100    137  
    0A    Spinup Retry Count    60    100    100    0   
    0C    Power Cycle Count    0    100    100    14  
    BF    Mechanical Shock    0    100    100    0   
    C0    Power-Off Retract Count    0    100    100    1 
    C1    Load/Unload Cycle Count    0    99    99    12127   
    C2    Temperature    0    152    152    19, 36  
    C4    Reallocation Event Count    0    100    100    0   
    C5    Current Pending Sector Count    0    100    100    0  
    C6    Offline Uncorrectable Sector Count    0    100    100    0  
    C7    Ultra ATA CRC Error Rate    0    200    200    0  
    DF    Load/Unload Retry Count    0    100    100    0   
    I'm pretty sure that the data is correct, because I can hear the HDD's Load / Unload sound very frequently. The C1 row increase about 2,000 per day.  However my previous Hitachi 5K320 has no problem. The running operating system are both Windows 7.
    I'm so worry about this. As you know, laptop HDD's L / UL Cycle is designed at 600,000. If my HDD continue increasing like this, it will reach this number in a very short time. Any one can help me?

    It's a feature of modern 2.5" harddisks , the disk parks the head when its been inactive for a while, to avoid damage , uses less power , and reduces the heat etc gives the harddisk a better looking spec sheet , its meant to park its head after being inactive for a long time around an hour with proper management from the bios/os of the head parking feature, because there is nothing to manage this feature in hp's bios or os the disk parks the head about every minute for no reason then after 1 second the head goes back on the disk thats 1 load/unload cycle , it also effects performance as the head has to find its place back on the disk , load times will decrease by alot , videos will stutter the first few secs, i have the same problem but not as bad after 130 hours i had a count of around 1,250 load/unloads , different brands of disk have different idle timers plus i use utorrent which stops the harddisk from idling so much, there are a couple of solutions, you can find a tool to update/mod the harddisk firmware to increase the idle timer ( i decided against this as you can permently brake the harddrive and void the warrenty) , contact hp and request a bios update with proper management or the harddisk head parking feature i.e tell the harddisk it is idle after an hour, the temperary solutions are download hd tune and run it all the time this stops the harddisk from parking its head as it doesn't let it go idle , or the solution i am using at the moment download a programme called HDD scan , everytime you turn on/off  you have to run the prog go to tasks/features/ide features set the advance power management from its default value to 254 then press set, no more unnessary load/unloads, downside is the disk runs a couple of 0c hotter mine still never goes above 40c even under full load thanks to a active cooling pad, also its less well protected against shock.

  • I Ask About WCS count Client not same WLC

    WCS  count Client not same WLC   as on WLC count client  = 100
    on WCS count = 23-23  
     Wireless Control System  Version 5.2.148.0
     WLC  7.0.250.0
    http://postimg.org/image/9boldeqd5/
    http://postimg.org/image/l482i9poz/

    Your WCS should have a higher (or not equal) version to your WLC.  
    I wouldn't even consider troubleshooting WCS problems if your WCS is running 5.X because WCS/WLC firmwares 5.X are very, very buggy.

  • Itunes regularly "forgets" my libraries and play counts

    Hi,
    In the last month i am experiencing the following problem. Every now and then, when i open itunes, my playlists are gone, and the play count of the songs is changed (a few songs have play count 1 and the rest 0). Moreover, itunes says I have a different number of podcasts downloaded.
    The situation lasts for a few days, and after a random amount of time, my playlists are back, including the play count of the songs(most songs above 100 play count) and i get a different number of podcasts.
    Not it seems to me i have two itunes, and every sync with the iphone requires the data on the phone to be deleted and freshly installs all sync songs/podcasts. This makes every sync 30 min long.
    In the itunes folder i have:
    itunes library extras.itdb
    itunes library genius.itdb
    itunes library.xml
    itunes library.itl
    itunes music library.xml
    i found that itunes music library.xml contains information with play count 1 or 0
    however the itunes library.xml contains the original infomation, with fields of play count a 100 or above.
    My first thought was to delete the itunes music library. I found that whenever i restart itunes the file is automatically generated.
    How can i stop this "random forgetfullness" of itunes?

    Do you have Windows Live OneCare or some other security software? Tell that software not to scan the ITL and XML files. That can cause problems when itunes is trying to save/update those files while the security software has a hold on it.
    Also - the "itunes music library.xml" is left over from an older version. I am fairly certain the newest versions of itunes uses "itunes library.xml".
    If it was my PC, I would delete "itunes music library.xml". You could always just move it to another folder if you are hesitant to delete it, but get it out of the itunes folder.
    Backing up, itunes needs an ITL file to run.
    1) If no valid ITL file exists, it creates a new one (blank library) and ignores the XML file.
    2) If it finds an existing ITL, it uses it and ignores the XML file.
    3) If it finds a valid but damaged ITL, it looks for an XML file and tries to rebuild the ITL from that.
    I suspect what is happening in your case is #3, but itunes is using the older xml with the bad play counts to rebuild its ITL file. If you get rid of that bad XML file it will have no choice but to use the recent XML file to rebuild.
    Of course the main reason of why this is happening needs to get sorted, but sometimes it's difficult to find what's causing the ITL problems in the first place. I'd look at security software settings and make sure the itunes database files are excluded.
    Just curious, if you look in Win Explorer, what are the dates on those XML files - created and modified?

  • Record counter question

    Right now, my report looks like:
    Category           invoice number             invoice counter
          A -
    100----
    1
    Result -
    1
          B -
    100----
    1
    Result -
    1
    Overall Result -
    1
    I know the overall result is correct, however the sum of category's result (2) is not equal to overall result.
    Is there any way to show category A (or B)  result as 0 since the invoice number is the same ?
    Thanks!
    Edited by: wawzj619 on Feb 5, 2010 12:00 AM

    Hi.
    Since the same invoice is valid for both categories, the correct value is what you are getting now.
    However, you can consider implementing your own count, where you assign to each category the share of the invoice, either applying a weighted approach based on the invoice value for each category or unweighted. This will give you 0,5 invioces per category in your example and the total will be 1.
    Thus it can and has beeen done, but I think counting this way is not logical as you will be getting fx 8,21 invoices for a category and how can you interpret this number? Or, in you example, category A did NOT receive just half an invoice! They got a whole one. And so did category B. The fact that it's the same invoice does not mean each category received just half an invoice!
    If you want your overall result to be the sum of invioces across categories and thus display "2" in your example, you can set the "calculate results as..." to "total" for the counter key figure. But the number 2 would - to me - be incorrect, because you only got 1 invoice...
    regards
    Jacob

  • Play counts are screwed up- why?

    And how do I fix it?
    What I mean is, recently, I am not sure when...but before I got iTunes 7, many of the play counts for my songs were altered somehow, so that they were incorrect.
    For example, it says my top played song is Pretty Woman, by Van Halen, and that I have listened to it 891 times. All of my other top 25 are also screwed up a lot...a bunch of songs I listen to have their play counts over 100.
    I don't know how it got this way, or how to fix it. Any help would be greatly appreciated.
    Thanks.

    I've had this before. Your library may have gotten corrupted, and you're just seeing it now. You might want to create a new library. You can do this by holding down the shift key when opening iTunes (option key if you are using a Mac).
    I did this when 7.0 first came out, and I have not seen the problem return.
    If you're syncing an iPod, you should sync it first, then restore, then rebulid your library.
    PowerBook G4   Mac OS X (10.4.7)   Remaining generally positive under unbearable stress.

  • Count of order number

    Hi,
    How to get list of year and count of orders_number from a table?
    Year       Count
    2000        100
    2001        150
    2002        0
    2003        212even though there is no data in table for year 2002, it should display 2002 with 0 count
    where to_char(order_year,'YYYY) between 2000 and 2003Thanks
    Sandy

    I think you need to create a table that holds all the years that you want to count upon. Then you can join your orders table with that "yearlist" table. This "yearlist" table can be a virtual table that is created on the fly useing some different approaches.
    example startyear=2000, endyear= 2005
    /* using hierarical select with connect by */
    with yearlist as (select 2000+level-1 as yr
                  from dual
                  connect by level <= 2005-2000+1)
    select * from yearlist;
    YR
    2000
    2001
    2002
    2003
    2004
    2005
    /* using a dummy table that has enough rows */
    with yearlist as (select 2000+rownum-1 as yr
                from all_objects 
                where rownum <= 2005-2000+1
                order by yr)
    select * from yearlist
    YR
    2000
    2001
    2002
    2003
    2004
    2005adding your orders table should give someting like this
    untested
    with yearlist as (select 2000+rownum-1 as yr, to_date('01.01.'||to_char(2000+rownum-1,'fm0000'),'DD.MM.YYYY') as yrDate
                from all_objects 
                where rownum <= 2005-2000+1
                order by yr)
    select y.yr , count(*), count(distinct o.order_number)
    from yearlist y
    left join orders o on trunc(o.order_date,'year') = y.yrDate
    group by y.yr
    order by y.yrEdited by: Sven W. on Aug 25, 2010 6:49 PM - added example using the orders table

  • Up/down count edges: traditional daq vs daqmx

    Hello,
    I've inherited a program that uses an encoder to read the position of a torque-arm.  The program uses traditional daq.  The encoder position data is read using "Counter Read Buffer.vi".  Then, by simply casting the output of "Counter Read Buffer.vi" to an I32, the position data can be either positive or negative.
    1. Is this a valid method of using "Counter Read Buffer.vi"?  (I wonder because if I capture data as I move the torque arm back and forth, the data suggests that the encoder is not moving back to zero counts each time.  For example, the first time the arm is moved through its range, it might go from 0 counts to 100 counts; the second run may be from 10 counts to 110 counts, the third from 15 to 115 and so on).
    2. Is something this simple available in DAQmx too, or do I have to monitor each encoder point that I read to detect when the counter rolls over and handle it manually?
    Thanks in advance for any assistance!
    Chris

    Hello Chris,
    For the answer to your first question, this may be an issue with the DAQ device you are using. What exact device are you using?
    For the second part, the Measure Angular Position VI, found in the Example Finder under Hardware Input and Output»DAQmx»Counter Measurements»Position, is a good quadrature encoder VI for reading angular position.
    Try using this example and see if the behavior is different between the Traditional DAQ and NI-DAQmx code and let me know how it goes.
    Regards,
    Dan King

  • Adding count total column .

    Hi,
    I'm dealing with 9.2.0.8 so some restrictions may apply :).
    here is the case
    SQL> create table t (id number) ;
    Table created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t;
            ID
             1
             1
             1
             2
    SQL> select count(*), id , ratio_to_report(count(*)) over () *100 pct , count(*) over ()  from t group by id;
      COUNT(*)         ID        PCT COUNT(*)OVER()
             3          1         75              2
             1          2         25              2
    but I need last column as all rows in table so should be
    SQL> select count(*), id , ratio_to_report(count(*)) over () *100 pct , count(*) over ()  from t group by id;
      COUNT(*)         ID        PCT COUNT(*)OVER()
             3          1         75              4
             1          2         25              4
    how to rewrite that, ratio_to_report gives percentage which is quite good but need all rows .Regards
    GregG

    Hi,
    Do you need this?
    select count(*)
          ,id
          ,ratio_to_report(count(*)) over () *100   as pct
          ,sum(count(*)) over()  
      from t
    group by id;

  • Why is there call duration counter limit in s60?

    Hi,
    That limit does NOT apply to low-cost s40 devices but s60 Symbian phones like my E55.
    Problem: In Log menu > Call Duration > Total (All) Calls' Duration, the counter CANNOT exceed 99:99:99, which means 100 hours at total. When you have your total call duration counter over 100 hours, the counter returns back to track call durations from zero, 00:00:00.
    WHY?
    Symbian lacks most of this basic features when compared to s40 which is a shame!
    Any comment is appreciated!

    Probably beause someone at Nokia thought 10 years ago when it was first implemented that 99:99:99 would be enough, and because since then it never was important enough for anyone to bother changing because the priorities were elsewhere.
    Now, with Symbian in, more or less, maintenance mode, I don't expect anyone to change it any longer (unless some Nokia engineer with the power to fix it does it without asking for permission from anyone).

  • WLC 5508 Base-Ap-Count License Inactive

    Hello,
    I have two licenses on a WLC 5508 "base-ap-count permenant 100 Count medium Inactive" and "base-ap-count permanent 150 count medium In Use".  Should both the 100 and 150 be added up to make 250? Why is the 100 license inactive?  There is no option to make it active.

    Here is my status:
    show license summary 
    License Store: Primary License Storage
    StoreIndex:  0  Feature: base-ap-count                     Version: 1.0
            License Type: Permanent
            License State: Inactive
            License Count: 5 / 0 (Active/In-use)
            License Priority: Medium
    License Store: Primary License Storage
    StoreIndex:  1  Feature: wlc-virtual                       Version: 1.0
            License Type: Permanent
            License State: Active, In Use
            License Count: 1 /1 (Active/In-use)
            License Priority: Medium
    License Store: Primary License Storage
    StoreIndex:  2  Feature: base-ap-count                     Version: 1.0
            License Type: Permanent
            License State: Inactive
            License Count: 10 / 0 (Active/In-use)
            License Priority: Medium
    License Store: Primary License Storage
    StoreIndex:  3  Feature: base-ap-count                     Version: 1.0
            License Type: Permanent
            License State: Active, In Use
            License Count: 15 /15 (Active/In-use)
            License Priority: Medium
    Both 5 license and 10 license have the dropdown arrow available to delete. Is it ok to delete them?
    vWLC came with 5 AP then I added two 5 AP licenses.

Maybe you are looking for

  • How do I get the old iphones information to my new iphone? i have tried to synk it but it doesn't work

    my other iphone didn't work, so i got a new one. before i got the new phone i saved all the information, and when you then put the new iphone into itunes it should be asking you "do you want to update this to eg. "david's iphone"?" but it didn't ask

  • Debugging a  XML Transformation Program

    Hi, We are converting incoming XML into ABAP structure and checking if the data has any future effective changes. If there is a future effective update, then it is converted back to XML string and stored in a custom table as a XML string. A job which

  • 64 bits IE can't display Gorden & Gotch PDF file

    When use 32 Bits IE, the desplay is correctly. But when use 64 bits IE, will show this message Sorry, you don't have adobe reader installed on your machine. Download Adobe Reader that suits your system from one of the following links. Don't close thi

  • Ipad can't get maximum of 802.11n (40 Mhz channel, 300 Mbps)

    Hi, Gens! I have TP-Link 1043 with OpenWRT. My WiFi is 802.11n with 20 MHz width at 2,4 GHz and 40Mhz width at 5,2 MHz. Encryption is WPA2 with AES My laptop connects at follwoing RX/TX rates: 180.0 Mbit/s, MCS 12, 40MHz 270.0 Mbit/s, MCS 14, 40MHz W

  • Integrate Sharepoint with EP

    Morning! With the newest EP version, is the integration with Sharepoint possible? And if so, any blog available? Thanks!