PostgreSQL - SPLessons

PostgreSQL Expression

Chapter 10

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PostgreSQL Expression

PostgreSQL Expression

shape Description

PostgreSQL Expression are the sequences of multiple esteems, operations and PostgreSQL capacities that assess through a quality.PostgreSQL Expression are resemble equations that are composed in query dialect. And these PostgreSQL Expression will get utilize to queries that database consisting for particular arrangement of information.

shape Syntax

The syntax for PostgreSQL Expression is as follows:
Select <column1><column2>,<columnN>from <table_name> where

[Condition|Expression];

Table_name => Any accurate table in the database.

Column_name => The columns that are inserted in the table.

Expression types

shape Description

And the expression in postgreSQL can be classified into 2 types

PostgreSQL Boolean Expressions

shape Description

PostgreSQL Boolean Expressions bring the information on the premise of coordinating individual esteems.

shape Syntax

Select <column1><column2>,<columnN>from <table_name> where single value watching value matching Expression.

Table_name =>Any accurate table in the database.

Column_name =>The columns that are inserted in the table.

shape Examples

By viewing the below example the concept of PostgreSQL Boolean Expressions can be easily understands.

SQLDB=# select * from Employee;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
SQLDB=# SELECT * FROM Employee WHERE SALARY = 10000;
 id | name  | age | address  | salary
----+-------+-----+----------+--------
  7 | James |  24 | Houston  |  10000
(1 row)

Here in the above example,out of 7 rows in the table,we can retrieve only selected row based on where condition.

PostgreSQL Numeric Expressions

shape Description

PostgreSQL Numeric Expressions performs mathematical operations on entire table records.

shape Syntax

Select numerical_expression as operation_name from <table_name> where condition;
Table_name =>Any accurate table in the database.

Column_name =>The columns that are inserted in the table.

shape Examples

By viewing the below example the concept of PostgreSQL Numeric Expressions can be easily understands.

Sampledb=# SELECT (15 + 6) AS ADDITION ;
addition
----------
  21
(1 row)

Here in the above example, performing addition on two numbers which defines the result set.

Summary

shape Key Points

  • PostgreSQL Expressions – Are written query dialect.
  • PostgreSQL Boolean Expressions – Gives the information on individual esteems.
  • PostgreSQL Numeric Expressions – Performs aggregate operations.