Multiplying Two Columns in SQL Server

How can I perform operations such as Multiplying and Subtracting two columns in SQL Server?

Payment
PK - PaymentID
FK - PaymentTypeID
FK - OccupiedApartmentID **- InitalPayment - MonthlyRate - Balance** - PaymentDate
0

6 Answers

In a query you can just do something like:

SELECT ColumnA * ColumnB FROM table

or

SELECT ColumnA - ColumnB FROM table

You can also create computed columns in your table where you can permanently use your formula.

0
select InitialPayment * MonthlyPayRate as SomeRandomCalculation from Payment
0

Syntax:

SELECT <Expression>[Arithmetic_Operator]<expression>... FROM [Table_Name] WHERE [expression];
  1. Expression : Expression made up of a single constant, variable, scalar function, or column name and can also be the pieces of a SQL query that compare values against other values or perform arithmetic calculations.
  2. Arithmetic_Operator : Plus(+), minus(-), multiply(*), and divide(/).
  3. Table_Name : Name of the table.

This code is used to multiply the values of one column

select exp(sum(log(column))) from table

You can use the query:

for multiplication

Select columnA * cloumnB as MultiplyResult from TableName

for subtraction

Select columnA - cloumnB as SubtractionResult from TableName
select InitialPayment * MonthlyRate as MultiplyingCalculation,
InitialPayment - MonthlyRate as SubtractingCalculation from Payment

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like