Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. I dont get it :-) Get Discounted price by porcentage

I dont get it :-) Get Discounted price by porcentage

Scheduled Pinned Locked Moved Database
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexeiXX3
    wrote on last edited by
    #1

    Hi thanks for looking I have a weird situation here im doing a case on a column, i need to get the final price Price = 15.0000 Discount = 10 when '%' then dbo.vwProducts.Price * ((100 - dbo.Promos.Discount) / 100) Shouldnt this give a result of 13.5?? (15 * ((100-10)/100)) It gives .0000 If i change the 100 for a 10 it works!! It gives a result of 135.0000 (15 * ((100-10)/10)) = 135.0000 Whats happening??

    Alexei Rodriguez

    A S A 3 Replies Last reply
    0
    • A AlexeiXX3

      Hi thanks for looking I have a weird situation here im doing a case on a column, i need to get the final price Price = 15.0000 Discount = 10 when '%' then dbo.vwProducts.Price * ((100 - dbo.Promos.Discount) / 100) Shouldnt this give a result of 13.5?? (15 * ((100-10)/100)) It gives .0000 If i change the 100 for a 10 it works!! It gives a result of 135.0000 (15 * ((100-10)/10)) = 135.0000 Whats happening??

      Alexei Rodriguez

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Check your data types. I just tried it with price and discoutn as decimal and it worked. I changed discount to int and got zero. Hope this helps

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • A AlexeiXX3

        Hi thanks for looking I have a weird situation here im doing a case on a column, i need to get the final price Price = 15.0000 Discount = 10 when '%' then dbo.vwProducts.Price * ((100 - dbo.Promos.Discount) / 100) Shouldnt this give a result of 13.5?? (15 * ((100-10)/100)) It gives .0000 If i change the 100 for a 10 it works!! It gives a result of 135.0000 (15 * ((100-10)/10)) = 135.0000 Whats happening??

        Alexei Rodriguez

        S Offline
        S Offline
        Sgg245
        wrote on last edited by
        #3

        Hi, You are doing division and multiplication through only int datatype only. Do type-casting of one of the variables or value. say (price * ((100-10) / 10.0)) Hope this shud work 4 U... :)

        Regards SG

        1 Reply Last reply
        0
        • A AlexeiXX3

          Hi thanks for looking I have a weird situation here im doing a case on a column, i need to get the final price Price = 15.0000 Discount = 10 when '%' then dbo.vwProducts.Price * ((100 - dbo.Promos.Discount) / 100) Shouldnt this give a result of 13.5?? (15 * ((100-10)/100)) It gives .0000 If i change the 100 for a 10 it works!! It gives a result of 135.0000 (15 * ((100-10)/10)) = 135.0000 Whats happening??

          Alexei Rodriguez

          A Offline
          A Offline
          AlexeiXX3
          wrote on last edited by
          #4

          Datatypes were were the problem :-) Thanks a lot

          Alexei Rodriguez

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups