Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:17:40+00:00 2026-06-16T00:17:40+00:00

This question is almost the same with one of my previous questions, which can

  • 0

This question is almost the same with one of my previous questions, which can be found HERE

I have a field named: pa_value which keeps varchar records
Now this field contains records like:

 0,5582
 0,6985
 -0,1589
 0,9856
 -0,6589

I’m getting these results using the following code:

CAST (replace (p7.pa_value ,'%','') AS float (3,0)) as TotalMargin

What I’m trying to do is to remove everything and leave just 5 characters(or 6 if there is a -(minus) infront of the string).
It should be looking like this:

 55.82
 69.85
 -15.89
 98.56
 -65.89

I tried to cast it as a float and then to convert it to integer. I also tried the floor command, which is not for my case, without any success. I’m always getting a syntax error message. I believe that there is no way to do this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:17:41+00:00Added an answer on June 16, 2026 at 12:17 am
    SELECT p7.pa_value=CASE WHEN LEFT( p7.pa_value,1)='-' THEN '-' + 
               CONVERT(varchar(max),CONVERT(float,substring(p7.pa_value,4,4))/100) ELSE 
               CONVERT(varchar(max),CONVERT(float,substring(p7.pa_value,3,4))/100)  END
    FROM <table_name>
    

    What is being done ..

    • Check if starting character is ‘-‘.
    • If yes then extract string starting from position 4 else starting
      from position 3.
    • The inner convert function converts string to float for division and
      the outer convert changes back the resultant value back to varchar
      type.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Almost the same question as this one here: What's the easiest way to grab
This one is almost a philosophical question: is it bad to access and/or set
UPDATED FOR CLARIFICATION I posted a similar question a while back found here which
Note: This is a sequel to my previous question about powersets. I have got
This question is very similar (or almost identical) to In a non blocking socket
I am almost embarrassed to ask this question, but as a long time C
This is almost certainly a very silly question, but for some reason I'm having
This question is similar in concept to this one , except I see I
I don't know if this is a dumb question but I have this two
In my previous question on this portal, I had asked about some insight about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.