12 Commonly Used SQL Operators

In SQL, an operator is a special character or keyword specifying an action that is performed on one or more expressions.

SQL operators are an integral part of SQL, and they enable us to write queries that return relevant results.

In this article, I present 12 of the most commonly used SQL operators when writing SQL queries.

Read more

SQL Operators

This article provides a list of SQL operators, and can therefore be used as cheat sheet for SQL operators.

Not all of these operators are supported across all DBMSs. If in doubt, check the documentation for your specific DBMS.

Read more

What Do I Need to Run SQL?

I get it. You’re trying to learn SQL, but they won’t even tell you the most fundamental part – what you need to run SQL!

You’ve got the SQL code… but where do you actually run it? What software program do you need before you can run your SQL query against a database?

If that’s you, all is about to be revealed!

Read more

SQL Server CASE Expression

In SQL Server, the T-SQL CASE expression is a scalar expression that returns a value based on conditional logic. It evaluates a list of conditions and returns a value, based on the outcome of those conditions..

In some ways, the SQL Server CASE expression is similar to IF...ELSE. However, CASE allows you to check for multiple conditions, whereas IF...ELSE doesn’t.

Read more

How to Write an ORDER BY Clause with Exceptions using SQL

In SQL, the ORDER BY clause is commonly used to order the results of a query. It allows you to select one or more columns to order the results, and in most cases, it’s probably all you need.

But what if you need to make an exception?

What if you want the results to be ordered alphabetically, except for one row? Or several rows?

Or perhaps you simply want to put any NULL values to the end, while ordering the non-NULL results.

Either way, there’s a neat trick you can use that will enable you to do this. And the good part is, it’s simple.

You can cater for all of the above scenarios by adding a CASE expression to your ORDER BY clause.

Read more