Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiplying Two Columns in SQL Server

Tags:

sql

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 
like image 614
Vonn Liquiran Avatar asked Sep 24 '11 04:09

Vonn Liquiran


People also ask

How do you multiply in SQL Server?

The SQL multiply ( * ) operator is used to multiply two or more expressions or numbers.

How do I calculate between two columns in SQL?

Finding Percentages between two columns is straightforward. You can simply use the column names and the division operator “/” to divide values in one column by another. The result is a list of values that correspond to the result of the division of all the values in the two columns.


1 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.

like image 151
Nigel Whatling Avatar answered Sep 19 '22 22:09

Nigel Whatling