How to Use Arithmetic Expression in SQL

In this article I am going to explain how to work with arithmetic expression in SQL
  • 3686

Introduction

In this article I am going to explain how to perform arithmetic operations on data stored in database table. We can perform operation on data stored in two or more than two columns and resultant data can be stored in new column. SQL support all arithmetic operators ( multiplication, division, modulo, addition, subtraction).

Order of precedence of arithmetic expression

  1.  Multiplication  ( * )
  2.  Division  (/)
  3.  Modulo (%)
  4.  Addition (+)
  5.  Subtraction   (-)

A Statement that create mcninvoices table

Clipboard10.jpg

Statements that insert data in mcninvoices table

Clipboard12.jpg

A Statement that is used to fetch data from mcninvoices table

Clipboard18.jpg

A Statement that calculate the balance due

Clipboard16.jpg

A Statement that calculate discount

Clipboard14.jpg


© 2020 DotNetHeaven. All rights reserved.