SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,948 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am calculating salary using below query
SELECT '29' as Total_Days,'28' as Present_Days,
(14000 / 29) AS Per_Day,
(14000 / 29) * 28 AS Total_Salary;
But Total_Salary should be 14000 because Total_Days 29 and Present_Day 29
Well, multiply by 29 rather than 28 then.
But keep in mind that when you divide two integers you get integer division. That is the result of 14000 / 29 is 482 sharp, not 482 comma something. To get a division which includes the remnant, you need to cast at least one of the operands to a data type that handles decimals, for instance decimal or float.