datetime tune date into pad dynamic cursor money percent sp job isnumeric while over update
FREE TRIAL  SQL 2012 PROGRAMMING  SEARCH
SQL Server Scripts SQL 2005 SQL 2008 Articles
SQL JOBS NEWS FORMAT DEV JOBS
How to force floating-point arithmetic on integer columns?

Execute the following SQL Server T-SQL script in SSMS Query Editor to force floating-point arithmetic by using 100.0 as a multiplier:

USE AdventureWorks;

 

SELECT   a.SalesOrderID,

         LineTotal='$'+CONVERT(varchar,convert(money,a.LineTotal,1)),

         PercentOfBase = CONVERT(DECIMAL(8,1),100.0 * a.OrderQty / b.TotalQty )

FROM     Sales.SalesOrderDetail a

         INNER JOIN (SELECT   SalesOrderID,

                        TotalQty = sum(OrderQty)

               FROM     Sales.SalesOrderDetail

               GROUP BY SalesOrderID) b

           ON a.SalesOrderID = b.SalesOrderID

ORDER BY a.SalesOrderID DESC,

         a.LineTotal DESC;

        

/*

SalesOrderID      LineTotal   PercentOfBase

75123             $159.00     33.3

75123             $21.98      33.3

75123             $8.99       33.3

75122             $21.98      50.0

75122             $8.99       50.0

75121             $35.00      33.3

75121             $34.99      33.3

*/

------------

Exam Prep 70-461
Exam 70-461