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.
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!
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.
If you use Azure Data Studio for your database admin tasks, you might be wondering how you can view the execution plan for your queries?
Fortunately, this is easy!
You have the option of viewing:
Comparison operators are an important part of most programming languages.
Comparison operators are used to compare two expressions. The result is either true or false. It could also be unknown. This could also be represented by either 1, 0, or NULL, depending on the language. These are typically known as “Boolean expressions”.
When used with databases, comparison operators can be used inside your SQL queries to filter data to a certain criteria.
I thought it would be interesting to run a few quick queries to see how various formatting strings affect the formatting of date/time values.
In PostgreSQL you can use the extract() function to get the week number from a date.
You can also use the date_part() function to do the same thing.
In PostgreSQL you can use the extract() function to get the day from a date.
You can also use date_part() to do the same thing.
When extracting the day from a date, you need to specify what sense of the word “day” you mean. For example, “day of week”, “day of month”, “day of year”, etc.
In PostgreSQL, you can get the day name from a date by using the to_char() function. This function returns a string based on the timestamp and the template pattern you provide as arguments..
In PostgreSQL you can use the extract() function to get the year from a date.
You can also use the date_part() function to do the same thing.