Converting from Access to SQL - CDBL Question

  • Hi All

    I need some help converting these into the proper statements that will work in a Stored Procedure for SQL:

    CDbl(Format(([Quantity]*[UnitCost]),"General Number")) AS ExtendedCost

    CDbl(Format(([Quantity]*[UnitPrice]),"General Number")) AS ExtendedPrice

    CDbl([ExtendedPrice]-[ExtendedCost]) AS GrossMargin

    IIf([ExtendedPrice]<>0,Format(([GrossMargin]/[ExtendedPrice]),"Percent")) AS Percentage

    Thanks for your help

    Bill

  • CAST(CONVERT(varchar,[Quantity]*[UnitCost],1) AS float) AS ExtendedCost

    CAST(CONVERT(varchar,[Quantity]*[UnitPrice],1) AS float) AS ExtendedPrice

    CAST([ExtendedPrice]-[ExtendedCost] AS float) AS GrossMargin

    CONVERT(varchar,CAST([GrossMargin]/[ExtendedPrice]*100 AS int))+'%' AS Percentage

    Andy

  • case when extendedprice <> 0 then CONVERT(varchar,CAST(round([GrossMargin]/[ExtendedPrice]*100, 2) AS float)) else '0.00' end + '%' as percentage

    udo

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply