Friday 15 January 2016

Operator Precedence in Sql.

In this article, we will see Operator Precedence in Sql .

When a complex expression has multiple operators, operator precedence determines the sequence in which the operations are performed. The order of execution can significantly affect the resulting value.


Operators have the precedence levels shown in the following table. An operator on higher levels is evaluated before an operator on a lower level.


 +-------+----------------------------------------------------------------------------+
  | Level  |                                Operators                                                                 |
 +-------+----------------------------------------------------------------------------+
  | 1        |  ~ (Bitwise NOT)                                                                                      |
  | 2        |  * (Multiply), / (Division), % (Modulo)                                                      |
  | 3        |  + , - , & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR)             |
  | 4        |  =, >, <, >=, <=, <>, !=, !>, !< (Comparison operators)                         |
  | 5        |  NOT                                                                                                        |
  | 6        |  AND                                                                                                        |
  | 7        |  ALL, ANY, BETWEEN, IN, LIKE, OR, SOME                                               | 
  | 8        |  = (Assignment)                                                                                       |
 +------+-----------------------------------------------------------------------------+

Let's see the program for this.


































Thanks.

ORDER BY clause

In this article, we will see the  ORDER BY clause Sql.

The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sorts query results in ascending order by default.


Syntax

SELECT column_name, column_name
FROM table_name
ORDER BY column_name ASC|DESC

Let's see the program for this.




































Thanks.