Category Archives: SQL

SQL Tutorial – Learn sql language

SUM

SQL SUM Function The SUM function returns the sum of all values from the select. Null values are ignored. SQL SUM syntax SELECT SUM(column_name) FROM table_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Example select SUM(PRICE) from Training_Course; Results 2800

MIN

SQL MIN Function The MIN function returns the minimum value in the expression. SQL MIN syntax SELECT MIN(column_name) FROM table_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Example select MIN(PRICE) from Training_Course; Results 200

MAX

SQL MAX Function The MAX function returns the maximum value in the expression. SQL MAX syntax SELECT MAX(column_name) FROM table_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Example select MAX(PRICE) from Training_Course; Results 800

COUNT

SQL Count Function The COUNT function returns the number of items in a group. COUNT function returns an int data type value. SQL COUNT syntax SELECT COUNT(*) FROM table_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Example select COUNT(*) from… Read More »

AVG

SQL AVG Function The AVG function returns the average of the values in a group. Null values are ignored. SQL AVG syntax SELECT AVG(column_name) FROM table_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Example select AVG(PRICE) from Training_Course; Results 560

Self Join

SQL SELF JOIN A table can be joined to itself in a self-join. SQL Self Join syntax SELECT column_name(s) FROM A_table, B_table WHERE A_table.column_name = B_table.column_name; Test ID NAME PARENT_ID 1 aaa NULL 2 bbb NULL 3 ccc 1 4 ddd 1 5 eee 2 6 fff NULL 7 ggg 6 Example SELECT b.* FROM Test a, Test… Read More »

Cross Join

SQL CROSS JOIN The CROSS JOIN returns the Cartesian product of the tables involved in the join. SQL Cross Join syntax SELECT column_name(s) FROM A_table CROSS JOIN B_table; Test1 ID TITLE 1 aaa 2 bbb 3 ccc Test2 ID TITLE 1 ttt 2 qqq Example SELECT * FROM Test1 CROSS JOIN Test2; Results ID TITLE ID TITLE 1… Read More »

Full Join

SQL FULL JOIN The FULL JOIN returns all rows from the joined tables. SQL Full Join syntax SELECT column_name(s) FROM A_table FULL JOIN B_table ON A_table.column_name = B_table.column_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7 800 5 PostgreSQL 6 500 Certifications ID NAME PRICE ID_TC… Read More »

Right Join

SQL RIGHT JOIN The RIGHT JOIN returns all rows from the table B, whether or not there is a match with table A. SQL Right Join syntax SELECT column_name(s) FROM A_table RIGHT JOIN B_table ON A_table.column_name = B_table.column_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7… Read More »

Left Join

SQL LEFT JOIN The LEFT JOIN returns all rows from the table A, whether or not there is a match with table B. SQL Left Join syntax SELECT column_name(s) FROM A_table LEFT JOIN B_table ON A_table.column_name = B_table.column_name; Training_Course ID NAME DURATION PRICE 1 SQL 5 200 2 T-SQL 7 700 3 MySQL 5 600 4 PL/SQL 7… Read More »