Postgree SQL
Postgree SQL
RowsRecordsenregistrement.
Columnsfieldsattributs.
Diffirent data type are stored differently and take different space.
FROM DB;
NULL VALUES :
in SQL null represents a missing or unknown value.
We can use IS NULL and IS NOT NULL in filtering data
To select , identify and exclude missing values.
SUMMARIZING DATA:
AGRREGATE FUNCTIONS :
An aggregate function performs a calculation to several
values and return a single value.
COUNT() is an example of an aggregate function.
AVG() Return the average of the field’s values
SUM()Return the total of the field’s values.
MIN()Return the lowest value.
MAX()Return the highest value.
NOTE:
Aggregate functions perform an action to the
field but the arithmetic functions like (+ / * -)
perform an action to the row
SORTING RESULTS:
ORDER BY Can be applied on one or more field separated by
‘,’
it sort in ascending order (0->100) or (A->Z).
you can use ASC for ascending and DESC for
descending.
you don’t have to Select the field that you are
sorting on.
GROUPING RESULTS:
New Keyword: GROUP BY.
GROUP BY used to order data in groups.
We can use GROUP BY with multiple fields.
We can combine GROUP BY with ORDER BY.
OODER BY is always written after GROUP BY
FILTERING GROUPED RESULTS:
We cant use WHERE with GROUP BY instead we can use HAVING
RENAME TO newname
Column
VALUES(valC1,valC2)
UPDATE STATEMENT :
The update statement is used to change the data inside rows
the alter statement is used to change table structure
UPDATE TableName
Set ColumnName1 = NewVal1 …,ColumnNameN = ValN
WHERE Condition
DELETE STATEMENT :
Used to delete unwanted data .
This will all the row which satisfy the condition
DELETE FROM tableName
WHERE Condition
TIP :
If you want to delete the first N rows just type :
DELETE top(N) FROM tableName ;