Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Collapse OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Arithmetic

 
EMP
ID Name Country Salary
1 Vijay India 6000
2 Bill USA 8000
3 Kris France 3000
      SELECT  Name,

      Salary + 5		as      'Add',
      Name + ', ' + Country	as	'String Concatenation',
      +Salary			as	'Positive',
      -Salary			as	'Negative',
      Salary - 5		as      'Subtract',
      Salary / 5		as      'Divide',
      Salary % 7		as      'Modulo',
      Salary * 0.3              as      'Multiply'

      FROM    EMP
    
      
Output
Name Add String Concatenation Positive Negative Subtract Divide Modulo Multiply
Vijay 6005 Vijay, India 6000 -6000 5995 1200 1 1800
Bill 8005 Bill, USA 8000 -8000 7995 1600 6 2400
Kris 3005 Kris, France 3000 -3000 2995 600 4 900