Wednesday, September 9, 2009

Defining a Null Value

Null Value :
  • A null is a value that is unavailable, unassigned, unknown, or inapplicable
  • A null is not the same as a zero or a blank space
Example :
  • postgres=# select ename, sal, comm from emp;
ename | sal | comm
--------+---------+---------
SMITH | 800.00 |
ALLEN | 1600.00 | 300.00
WARD | 1250.00 | 500.00
JONES | 2975.00 |
MARTIN | 1250.00 | 1400.00
BLAKE | 2850.00 |
CLARK | 2450.00 |

Using Arithmetic Operators with SQL SELECT

Using Arithmetic Operators & Expressions :

Create expressions with number and date data by using arithmetic operators
  • + : Add
  • - : Subtract
  • * : Multiply
  • / : Divide

Example :

postgres=# select ename, sal, sal+100 from emp;

ename | sal | ?column?
--------+----------+---------
SMITH | 800.00 | 900.00
ALLEN | 160.00 | 1700.00
WARD | 1250.00 | 1350.00

  • The example in the slide uses the addition operator to calculate a salary increase of $100 for all employees. The slide also displays a SAL+100 column in the output
  • Note that the resultant calculated column SAL+100 is not a new column in the EMP table; it is for display only
Operator Precedence :
  • postgres=# select ename, sal, 12*sal+100 from emp limit 3;
ename | sal | ?column?
-------+---------+----------
SMITH | 800.00 | 9700.00
ALLEN | 1600.00 | 19300.00
WARD | 1250.00 | 15100.00
(3 rows)

Followers