Welcome to Sign in | Join | Help
in Search

Rotunjire

Last post 05-07-2014, 6:35 by xmldeveloper. 2 replies.
Sort Posts: Previous Next
  •  04-28-2014, 12:49 9647

    Rotunjire

    Salut
    Cum pot rotunji din TSQL
    835 / 30 * 15 sa dea 418
    Oricum am dat pana acum iese 417, iar beneficiarul imi tot arata cu un calculator de buzunar ca face 418.
    Mentionez ca rezultatul final se rotunjeste la intregi (0 zecimale).
    Sorin Sandu
  •  04-28-2014, 4:53 9648 in reply to 9647

    Re: Rotunjire

    Vad ca daca fac 835 * 15 / 30 da rezultatul asteptat
    Sorin Sandu
  •  05-07-2014, 6:35 9655 in reply to 9647

    Re: Rotunjire

    O solutie este folosirea CEILING:

    DECLARE @X DECIMAL(10,2)=835
    DECLARE @Y DECIMAL(10,2)=30
    DECLARE @Z DECIMAL(10,2)=15
    SELECT CEILING(@X / @Y * @Z)
    Cristian Andrei Lefter, SQL Server MVP
    MCT, MCSA, MCDBA, MCAD, MCSD .NET,
    MCTS, MCITP - Database Administrator SQL Server 2005
    http://sqlserver.ro
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems