January 10, 2011 at 6:57 am
83%
20%
67%
90%
60%
100%
I have the data like above. I need to get the number before % out. How do I accomplish this ? Thanks.
in the asp, I use this intScore = left(trim(Request.Form("percentage")), instr(trim(Request.Form("percentage")), "%")-1)
to get the score out?
Thx.
January 10, 2011 at 7:22 am
Would a simple REPLACE(YourValue,'%','')
do the trick?
January 10, 2011 at 7:24 am
yes.
select convert( int, (replace(score, '%','') )) as TScore from [Quiz log]
right now I need to just extract the TScore >80 . but when I
tried
select convert( int, (replace(score, '%','') )) as TScore from [Quiz log] where TScore >80
it gave me error as TScore as invalid column name.
I tried this way. I do not know whether there is a more elegant way to accomplish this.
select convert( int, (replace(score, '%','') )) as TScore from [Quiz log] where Score<>'Waived' and convert( int, (replace(score, '%','') ))>80
January 10, 2011 at 8:00 am
You could just query on WHERE score > '80%'
"greater than" will be calculated alphabetically here. Presuming your data is as one would expect, ie values between 0% and 100%
Not sure how well it would work with decimals though
Edit: seems to work okay with decimals
January 10, 2011 at 8:07 am
well , I think if there 100%. then it will different. Thx.
January 10, 2011 at 8:10 am
January 10, 2011 at 7:34 pm
mazzz (1/10/2011)
Frances L (1/10/2011)
well , I think if there 100%. then it will different. Thx.True. Trust me to worry about decimals and miss the obvious 🙂
Did you also check it for single digit percentages?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 11, 2011 at 4:56 am
I do not think I need to worry about single digit since I convert to int already. Thx.
January 11, 2011 at 4:58 am
Jeff Moden (1/10/2011)
mazzz (1/10/2011)
Frances L (1/10/2011)
well , I think if there 100%. then it will different. Thx.True. Trust me to worry about decimals and miss the obvious 🙂
Did you also check it for single digit percentages?
Good point. It would appear my brain neglected to return from the holidays at the same time as the rest of me did.
January 11, 2011 at 5:01 am
I am in the same mental state, too. Go back to work.Cheer.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply