Operators in SQL for Data Analysis
Data Analytics

Operators in SQL for Data Analysis

Comparison Operators — Numerical Data


Comparison Operators — Non numerical Data

All of the comparisons still work however they are done on the ASCII value (integer value equivalent of characters) and not the domain value.

Example : January comes before February but since F comes before J in the alphabet January > February :P

Note : While working with values always put them inside SINGLE quotes like ‘January’.


Arithmetic Operators

The above code will add the values in Colname1 and Colname2 and print it under the heading combined name for each row . Here combined name is the derived column.

The operators and columns can also be chained together like col1+col2*col3 and for specifying order in which operators are to be processed use round brackets like (col1 + col2)*col3.


Logical Operators

To supplement the WHERE clause and perform data filtering with more than one condition at a time, logical operators are used.


  • Allows you to match similar values, instead of exact values.
  • Values in columns can be compared to a given pattern.
  • % represents a single character or string of characters.
  • _ represents a single character only.
  • LIKE can be be substituted with ILIKE if the results should not be case sensitive.
  • Usage:


  • Allows you to specify a list of values you'd like to include.
  • IN can be used for both numerical and non numerical values.
  • Usage:


  • Allows you to select only values within a certain range.
  • Usage:


  • Allows you to select only rows that satisfy all conditions.
  • Conditions can comprise other comparison and arithmetic operators. Example : col1 + col2 < 6
  • Usage:


  • Allows you to select rows that satisfy either of two conditions.
  • Selects the row if any of the conditions evaluate to true.
  • Usage:


  • Allows you to select rows that do not match a certain condition.
  • Selects the row only if the condition evaluates to false.
  • Usage:


  • Salman Ps
  • Dec, 27 2022

Add New Comments

Please login in order to make a comment.

Recent Comments

Be the first to start engaging with the bis blog.