Strip alpha to take average

I have a table that looks like:
sub_dt date,
cd    varchar2(5),
day01 varchar2(5),
day02 varchar2(5),
day03 varchar2(5),
day31 varchar2(5))
sub_dt       cd       day01      day02      day03
01-JAN-06  A10    e5           e4            e5
04-FEB-06  A10    5             5              6
It contains daily measurement values for the given cd. Sometimes the data is entered as an estimate, so it is stored with a preceeding e. Why I don't know. But what I need to do is create two different types of averages:
1. The aveverage measurement by day - pretty easy avg(day01), avg(day02)...
2. The monthly average for the cd.
In either case I am stuck with these non-numeric values. What is the best approach for stripping out the alpha characters so that I can actually perform the math? I was thinking of using regular expresssion somehow, but I don't know if that is best. I was also thinking about creating a function to do a translate/replace of the alpha and return the number, but that is a whole lot of context switching - 31 times for each row.
Second is that the average over the month is a bit tricky. I think that I am stuck adding the data together and dividing by 31 - (day01 + day02 + day03)/31, but I think that creates potential for incorrect results. Image if someone only inputs data for three days out of each week, then really they only should be divided by 12 and not 31. So after I convert the data to number I would need to evaluate the nulls...analytics maybe?
I am guessing that I am making this more complicated than it really is and just need another pair of eyes to help me see forest through the trees.
Thanks, Tony

William -
The ltrim or substr would be a good method if I knew that the only letter was "e". I wasn't very clear about that part. Since it is a varchar2 field and this application has no data integrity this field can have just about anything in it. Someone could enter e or x or any other combination of letters prior to the actual number.
I like the collection idea, I will give that a shot.
<b>Updated:</b>
I used a combination of these two methods with really nice results.
select sub_dt,cd,avg(regexp_replace(column_value,'[^0-9]+','')) month_avg
from t, table(TableType(day01,day02,day03,....))
group by sub_dt,cd;
DT                  CD           MONTH_AVG
08/02/2006 08:49:40 0056                 4
08/03/2006 08:50:21 1001               145Thanks for the help, really great solutions.
Tony
Message was edited by: T

Similar Messages

  • My iphone 5 camera suddenly stop working and the shutter dont open after some minutes shutter open with some dolor stripes and it takes 2 or 3 days and again start working normaly it happens every 3 weeks.is this a soft ware problem??

    my iphone 5 camera suddenly stop working and the shutter dont open after some minutes shutter open with some dolor stripes and it takes 2 or 3 days and again start working normaly it happens every 3 weeks.is this a soft ware problem??

    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    Additional things to try.
    Try this first. Turn Off your iPad. Then turn Off (disconnect power cord) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    Change the channel on your wireless router. Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
     Cheers, Tom

  • ImageIO.read stripping alpha channel

    I've been chasing this one for the last few hours and haven't gotten anywhere.
    I've been trying to load a 32 bit bitmap (I'm using photoshop and I put a gradient on the alpha channel), and no matter what I do, I keep getting a 24 bit image from the api. I could really use some help on this one. This is the toString() of what should be a 32 bit image: BufferedImage@1f44f8a: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 72 height = 72 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    And here's the code I'm using to load the image:
    public Image Fetch(String path) throws CommonException
         BufferedImage image = null;
         try
             image = ImageIO.read(new File(path));
             System.out.println(image.toString());
         catch(IOException ex)
             Error(ex.getMessage());
            return image;
        }Thanks in advance.
    EDIT
    Here's the image I'm using: [http://img.photobucket.com/albums/v461/vaine0/thebitmap.jpg]
    Edited by: Ax.Xaein on Aug 1, 2009 2:03 AM

    I can probably help you, but you need to save the actual 32-bit bmp image on an image hosting sight so I can take a look at it.
    If the image data contained 4 channels of information, but the BMPImageReader used a destination image of only 3 channels, then you would get an IOException complaining that the source bands doesn't match the destination bands.
    And I'm pretty sure the BMPImageReader can read version 4 and version 5 bmp's (the ones that support an alpha channel).
    Are you absolutely sure you have a bmp with an alpha channel? Not many applications support writing v4 and v5 BMP's.

  • Clear array and take average of values in array continuously

    I have a continuous signal that I am acquiring with hardware (sampling at 1000Hz).  I want to be able to insert the data into a 1D array for 5 seconds, and then take the average of these 5000 samples.  So basically, every 5 seconds I need to take the average of a 1D array and create a new array for the next 5000 samples.

    There is no reason to accumulate the data into an array if all you need is the average.
    Simply add the values into a shift register. Every 5000 points devide the sum by 5000, output the average, and zero the shift register for the next series of data..
    LabVIEW Champion . Do more with less code and in less time .

  • Take 45s to boot a brand new Mac Pro

    Hi Mac Pro folks
    I just got a brand new Mac Pro running Mountain Lion. It came with a 512MB SSD as the boot disk and a 2TB disk as the second drive. What I got confused is: after powering it on, the Mac Pro takes average 45s to boot to the white screen with an Apple logo.
    This is actually the second Mac Pro, the previous one having the same configuration took 30 seconds to boot. As the previous one's second drive got clicking sound from the first day, Apple replaced the whole machine. Now the clicking sound has gone, but the second Mac Pro takes an even longer time to boot from SSD.
    Is it normal? Has anyone ever experienced the same thing?
    Thanks for any comments.
    Regards,
    B

    It should be Apple genuine SSD, as the 512 MB SSD comes with the new Mac Pro. Please see below its information retreived from System Report. TRIM Support is enabled.
    Intel ICH10 AHCI:
      Vendor:    Intel
      Product:    ICH10 AHCI
      Link Speed:    3 Gigabit
      Negotiated Link Speed:    3 Gigabit
      Description:    AHCI Version 1.20 Supported
    APPLE SSD SM512E:
      Capacity:    500.28 GB (500,277,790,720 bytes)
      Model:    APPLE SSD SM512E                       
      Revision:    CXM07A1Q
      Native Command Queuing:    Yes
      Queue Depth:    32
      Removable Media:    No
      Detachable Drive:    No
      BSD Name:    disk0
      Medium Type:    Solid State
      TRIM Support:    Yes
      Bay Name:    Bay 1
      Partition Map Type:    GPT (GUID Partition Table)
      S.M.A.R.T. status:    Verified
      Volumes:
    disk0s1:
      Capacity:    209.7 MB (209,715,200 bytes)
      BSD Name:    disk0s1
      Content:    EFI
    MACPRO_SSD:
      Capacity:    499.42 GB (499,418,034,176 bytes)
      Available:    175.82 GB (175,817,490,432 bytes)
      Writable:    Yes
      File System:    Journaled HFS+
      BSD Name:    disk0s2
      Mount Point:    /
      Content:    Apple_HFS
    Recovery HD:
      Capacity:    650 MB (650,002,432 bytes)
      BSD Name:    disk0s3
      Content:    Apple_Boot
    This is a Mac Pro 5,1 so I would expect it should take less than 10 seconds to boot.
    Moreover, the SSD is the only startup device under Startup Disk.
    It seems the only PCI card is the ATI Radeon HD 5770 that comes with the system.
    ATI Radeon HD 5770:
      Name:    ATY,Hoolock
      Type:    Display Controller
      Driver Installed:    Yes
      MSI:    Yes
      Bus:    PCI
      Slot:    Slot-1
      Vendor ID:    0x1002
      Device ID:    0x68b8
      Subsystem Vendor ID:    0x106b
      Subsystem ID:    0x00cf
      Revision ID:    0x0000
      Link Width:    x16
      Link Speed:    5.0 GT/s
    The hatter wrote:
    Probably trying to use a 512MB boot device?
    No it should take 10 seconds. That is what my SSD on Mac Pro 1,1.
    PCIe cards can affect booting, especially if you boot from one.
    3rd party SSD or not? \
    firmware is current?
    SSD is set to default startup disk control panel?
    You've done ML Recovery and checked the SSD twice: the top of the drive to check partitions, the user volume to check the system directory.
    If it is 3rd party what make?
    Does it show TRIM is enabled in SATA entry in System Profile?
    What else is installed.
    Does not sound normal to me to replace anything except the hard drive for clicking, and then to just zero the drive.
    I would never pay for disk drive from Apple when there are better prices and as good devices.

  • Average Clustering ratio is not going up to 1.0 even after dense restructure

    Gurus,
    good evening.
    I am having a strange issue.
    I did a force restructure using Maxl. The number of pag files reduced from 14 to 9 but when I check properties the clustering ratio is still showing the value in contrary to the expectation of 1.0
    I am in impression that the force restructure would remove fragmentation and take Average Clustering Ratio to 1.0
    please advise.

    Gurus,
    good evening.
    I am having a strange issue.
    I did a force restructure using Maxl. The number of pag files reduced from 14 to 9 but when I check properties the clustering ratio is still showing the value in contrary to the expectation of 1.0
    I am in impression that the force restructure would remove fragmentation and take Average Clustering Ratio to 1.0
    please advise.

  • When will Alpha conversion happen

    Hi Gurus,
    When will Alpha conversion take place if Infoobject has ALPHA as convers routine.
    After loading to Infoobject right? Not in PSA.
    Thanks Gurus.

    Hi,
       If conversion exist at definition of info object then it will hapeen at the time of extraction, else it will happen after PSA means where we definied like TR or UP.rules.
    Regards
    Sankar

  • BPS - No alpha conversion exit or similar provision?

    Dear BPS Experts,
    In the Flat File that we are loading to BPS Cube (using the HOW-TO Paper in SDN), if User is having a value 100000006 for Customer and value 10200058 for Material then the flat file upload exit fails. It works only when user changes the value for Customer to 000000000100000006 and value for Material to 0010200058.
    I believe, you must have understood my point.
    PROBLEM 1
    In BW, we have Conversion Exits like ALPHA that take care of internal to external format conversion and vice-versa. Unfortunately, in BPS, it seems system expects users to enter values as they exist in the master data tables like P Tables for Characteristics.
    QUE 1: Is my above understanding correct?
    We have many characteristics (25-30) in our file and I do not want to write a separate Exit to do any conversion like ALPHA, that would really slow down the performance.
    PROBLEM 2
    We have a field in the file called 'Manager Name'. Now this field can really have any value. It is not possible for us to load master data in BW for this field. If BPS is suffering from this basic limitation then I am afraid, we can not use it for loading flat file. We have to use only BW
    QUE 2: Is there any way, by which I can make BPS accept and load transaction data in BPS Cube even if some master data in that file does not exist. If so, then what is the way to go about it?
    I am aware of BW means to load Flat File data to BW/BPS Cubes. But we have many compelling reasons to use Planning Folder to load Flat File. Hence, if some expert can advice about overcoming these limitations with BPS then it would be highly appreciated.
    PS: I understand, functionally it does not make sense to plan for something which does not exist in master data. Having said so, there can be some exceptional situations and BPS being the sibling of BW, I expected it to have that capacity.
    Regards,
    Adi
    Edited by: Adi Kulkarni on Aug 13, 2009 3:13 PM

    Hi Deepti,
    I appreciate your link. That document is very good although it does not solve my problem.
    Please note that I am talking about loading a flat file to BPS Cube here and there may be hundreds of values which still do not exist in master data. Your suggested HOW-TO document will be helpful when someone tries to enter data in a planning layout as we do not expect users to enter so many records in planning layout.
    I am also aware that we can simply create a Z-Transaction Code (similar to RSD1) to update master data values for a particular InfoObject and Users can be given access to this code. But that is not what I intend to do.
    I am looking for a broader and generic solution.
    When we load a flat file to BW, we have an option in InfoPackage "Load Transaction Data even if no Master Data exists".. that kind of option or setting really along with something similar to ALPHA Conversion Exits.
    Hope my requirement is clearer.
    Regards,
    Adi
    Edited by: Adi Kulkarni on Aug 13, 2009 3:32 PM

  • Planning Average and Ending Exchange rate

    Hi i need some info regarding average and ending exchange rate in the exchange rate tables.
    On what factors the the exchange rates are stored ,how are they entered.
    Thanks in advance

    Hi Lakshmi,
    We usually take Average Exchange Rate for Revenue Accounts and Ending for Balance Sheet accounts. Depend on the nature of Account we will choose the type of exchange Rates. For ex. in Jan you've the exchange rate as 45 (USD to INR) and in Feb if it is 48 and in March if it is 50, For Qtr1 you should take March exchange Rate for Balance sheet accounts. Where as when dealing with Revenue Account, the exchange rate should be the avg of Jan, Feb & March. Hope this helps

  • IMovie6 make automaticly black stripes on top/bottom

    When I imported from my Sony DCR HC44E (wide screen 16:9) into iMovie 6 and take shots to the archive the program automaticly make black stripes so it takes a lot of time and some details are missed afterwars. How can I change this after record 16:9 into iMovie and burn this to DVD?

    Also I have found this on the export video screen which narrows it down a bit...
    Here's how the source tab of that screen looks...
    compared to the output tab, with the black bars that are my issue...
    So where did I go wrong here?

  • Startup time in dev alpha c

    My dev alpha c take more than 2mins to start. anyone with same problem?

    Hi fotodng,
    I have sent you a private message with the steps you need to take regarding your Dev Alpha device.
    Let me know if you have any further questions.
    Thanks!
    -HMthePirate
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • GrandTotal Average calculation.

    Hi
    My report has following fields.
    Tower, Prjid, Rating.
    I want to dispaly total number projects and average rating of projects  for each tower.
    so i group the data by towr wise.
    i am using this formula to calucate toweraverage rating
    @toweravg= Sum ({TOWERSUMMARY.OverallRating}, {TOWERSUMMARY.Tower}) / Count ({TOWERSUMMARY.ProjectCSSId}, {TOWERSUMMARY.Tower})
    for calculating grandavg i am using
    avg(@toweravg) , but this formula showing error liike  This field can not be summarized.
    So how to calculate grandtotal of  avg?
    sample data:
    1 4.00
    2 2.50
    i want in the end like
    3   3.25((4.00+2.50)/2)

    I am asuming you are getting 4.50 and 2.00 from this
    Count ({TOWERSUMMARY.ProjectCSSId}, {TOWERSUMMARY.Tower}
    You have to use the same without the last bit i.e.
    Count ({TOWERSUMMARY.ProjectCSSId})
    and place it under Report footer.
    This will count all of the above.
    Then use that and take average.
    Regards
    Jehanzeb

  • How do I automatically log the battery percentage and time on my Retina Macbook Pro to an excel spreadsheet? (OSX 10.9.4)

    Hello! So I own a 13" rMBP, and I'm running OSX 10.9.4.
    How do I log my battery percentage with the date, probably down to the hour, preferably to an Excel file?
    I want to track the rate at which my battery discharges, so that in the future I can compare the present rate of discharge with the past and see exactly how much my battery has deteriorated by. I'll take averages over long periods of time to account for, e.g. the fact that watching Netflix drains my battery faster than editing an essay. I also want a solution that uses negligible power in the background.
    I've spent hours looking for an app that both calculates the rate of discharge and keeps all data, but I haven't found any. Eventually I decided that hopefully it isn't too difficult to write an AppleScript or something that simply logs the system clock and battery percentage in tandem every hour or so.
    Thank you for your time!
    Herman

    What Barney said.
    Here is the script to create a CSV text file with
    Date
    Time
    Current Battery Percentage as an integer
    #!/bin/bash
    batterycsv="$HOME/battery.csv"
    export GREP_OPTIONS="--color=never"
    # if you want the percentage sign too, exclude the second egrep
    battpct=$(pmset -g ps | egrep -o "(\d+)%" | egrep -o "\d+")
    datetime=$(date "+%Y-%m-%d %H:%M")
    printf "%s,%s,%s\n" $datetime $battpct >> $batterycsv
    Output on a fully charged MacBook Air to battery.csv will be individual lines of the following format:
    2014-08-09,19:49,100

  • Pages freezing up

    Hi,
    I create documents in pages Layouts with many images. I have had on-going problems with the pages freezing up and not being able to manipulate images or move around the document. Ball starts spinning and application can not keep up with commands. I have been instructed to re-install my operating system twice now by apple (which allowed pages to work for a few weeks then back to same problem). I have been on the phone countless hours with techs taking me through various hopeful fixes. Still doesn't work. I have removed pages 09, and Apple sent me new Iworks 09 software. The problem is worse. DOES ANYONE HAVE ANY CLUE AS TO FIXING THIS PROBLEM?
    Thanks!

    gabmhart wrote:
    Hi,
    Thanks for the welcome!
    The images I use are normally jpegs that I either copy/paste or drag into pages. the images are normally 1-2 mb in size.
    Large numbers take up resources. Depending on compression method, 1-2mb could be large files. The final size needs to be 300dpi and no more.
    Sometimes smaller. I usually just mask the images and I do use Alpha to take backgrounds out.
    Alpha masked images will especially tax the system. Better to prepare images "deep etched" ie background removed in Photoshop or the like.
    I add text boxes to the pages with limited text. Apple has said that Pages should be able to handle docs that have higher mbs and that I should not be having this issue. But I agree it has to do with the images. I am now breaking up and doing single pages but even then it is freezing up. It is odd but I find that the problems get gradually worse. I can create a page with images and manipulate it just fine and then 2 weeks later open the same page and nothing responds. Very frustrating. I am now told by apple that I need more RAM but the fact that I sent a 7 mb doc to a MACPRO user with much more power and she had the exact same issue makes me question that.
    Thoughts? I am brain dead from this.
    Trim and simplify. 20 years of experience. The computer has only limited resources.
    Peter

  • 3D files in After Effects CC

    Isn't that like saying, you didn't meet your own deadline? I'm glad it has worked towards yours and C4$D's advantage.. $$$$
    Anyway, I am a whole hearted Blender Freak. On my 4th year now. You can do almost anything in Blender, and since it's such a steep learning curve, the challenges it brings makes it where you can eventually learn any other program after getting it down. Unfortunately, when collaborating with other animators, editors, etc, they're all stuck in the Maya, C4D (both of which are much more user friendly that Blender) . Adobe pool... So in a sense, I'm stuck in that same pool. The reason I'm here is because I too just spent a $$$load of money. I got a refurbished  Macbook Pro Maverick op system and a bunch of software only to find out that the Mac has a serious common issue with it's airport card. I gor the Adobe stuff as a packaged deal whn buying the Mac. Now I couldn't help but notice that This AE news reminds me of the issue Mac has. The only difference is that Mac won't address the issue or own up to it, llike Adobe is at least doing. . They'd rather you spend more on another Mac since fixing the issue with a specialist will more than likely advise you just purchase oh,,, uh.... duh... let me think,,,, ANOTHER MAC! It'll cost just as much anyway right?
    I don't know what utopian economy a great number of the artists here seem to live in, but the rest of us are struggling our ***** off while pursuing our art. Face it, these shortcomings are like the dangling carrot routine. Look what you can do with our product/ no you can't do that with our product anymore, but here's a great alternative, all you need  to do is shell out a few extra hundred dollars more!  
    So with that said, if you're not rich, or you're just starting out, or barely getting your career off the ground, don't waste a dime on C4D, 3DX, Maya or any of those obscure programs that costs some snotty rich kid's salary, AND DO NOT TRUST THIS NEW CINEMA 4D DEAL WITH AE! JUST DON'T. It's a lead in to get you buy the professional C4D, and if you're not in a position to step into that, then know that you can attain the same quality of effects without them. I strongly believe that most artists should go with a community based support group like Blender, Gimp, Make Human, etc.. and stay plugged in for their upgrades. There are ways of working around some of these, for lack of a better word, crooks. Adobe is awesome, but why are so many people share our frustration with them, right? Blender is even getting way more user friendly than it was just 2 years ago.
    For example, What I do is animate my scenes in layers one at a time in my awesome 3d program that is free, use the same camera for all of them (they're all in layers anyway), render them with alpha channels, take the clips, dump them into AE, jiggle AE's knobs (since the clips are all aligned anyway) jiggle some effect knobs (the cc ones work just fine, you don't necessarily need that particular trapwhatever, just use your creativity and imagination), then flush the scene out into a nice QT format.... Fortunately Final Cut Pro X has improved it's dastardly flaws since it's initial release, and it's affordable. I'm happy to say that I'm actually using it more than FCPro 7 now, which is a major statement. I have Adobe Premier Pro, I was going to try it, but I'm discouraged for now, Maybe next year when the current version is obsolete. 

    Has the trial for After Effects CC expired?
    You are allowed to launch After Effects CC one time after the 30-day trial period has expired, but when you do so a a bug exists in this state: MPEG2 files can not be read or written.
    The only solution for this bug is to license After Effects CC; ex. purchase a subscription. My apologies for the problems you're having with the payment system. As Rick says, please contact customer support for help with this.

Maybe you are looking for

  • Last Price Report

    Hello experts, in a Sales order when doing ctrl+tab on the price after discount, a "Last price report" pops up with various selection criterias, do you know if we could get this report from the menu or somewhere else without having to go thu the SO?

  • Since the Yosemite upgrade on my macbook pro I have not been able to sync with my Nokia Lumia

    Since the Yosemite upgrade on my macbook pro I have not been able to sync with my Nokia Lumia and assume that this is an Apple issue?

  • Uninstalling SDK 1.4.0

    Hi, I had install SDK 1.4.0 but find that some of my program cannot work with it, so I re-install/overwrite it with JDK 1.3.1, but my program still use the path of my SDK 1.4.0, I had re-install both the program and JDK 1.3.1 a few times already. I a

  • Is it Possible to change your Apple ID

    Is it possible to change your apple ID (the email address) I need to change my email provider and would prefer to have everything under one account if possible

  • Keyboard setting (language) not saved in multiple user setting

    Since I added multiple user profiles to my MacBook Pro, the system seems to forget the settings of the keyboard (Dutch / belgium) and reverts always to US. The Dutch setting is deleted then.  This happens in all user accounts. I have another MacBook