• SQL – Group By

    SQL – Group By

    SQL – Group By Table Of Contents: What Is SQL Group By ? Syntax Of SQL Group By. Examples Of SQL Group By. (1) What Is SQL Group By? The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”. The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result set by one or more columns. (2) Syntax Of SQL Group By? SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name(s); (3) Examples Of SQL Group By? Example-1 SELECT COUNT(CustomerID), Country FROM Customers GROUP

    Read More

  • SQL – Union

    SQL – Union

    SQL – Union Table Of Contents: What Is SQL Union? Syntax Of SQL Union. Examples Of SQL Union. (1) What Is SQL Union ? The UNION the operator is used to combine the result set of two or more SELECT statements. Every SELECT statement within UNION must have the same number of columns. The columns must also have similar data types The columns in every SELECT statement must also be in the same order (2) Syntax Of SQL Union ? Syntax: UNION Syntax SELECT column_name(s) FROM table1 UNION SELECT column_name(s) FROM table2; Syntax: UNION ALL Syntax SELECT column_name(s) FROM table1 UNION ALL SELECT column_name(s) FROM

    Read More

  • SQL – Self Join

    SQL – Self Join

    SQL Self Join Table Of Contents: What Is SQL Self Join? Syntax Of SQL Self Join. Examples Of SQL Self Join. (1) What Is SQL Self Join? When you are joining the same table to itself it’s called Self Join. (2) Syntax Of SQL Self Join Syntax: SELECT column_name(s) FROM table1 T1, table1 T2 WHERE condition; (3) Examples Of SQL Self Join Customer: Example-1: SELECT A.CustomerName AS CustomerName1, B.CustomerName AS CustomerName2, A.City FROM Customers A, Customers B WHERE A.CustomerID <> B.CustomerID AND A.City = B.City ORDER BY A.City;

    Read More

  • SQL – Full Outer Join

    SQL – Full Outer Join

    SQL Full Outer Join Table Of Contents: What Is SQL Outer Join? Syntax Of SQL Outer Join. Examples Of SQL Outer Join. (1) What Is SQL Outer Join? The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records. FULL OUTER JOIN and FULL JOIN are the same. (2) Syntax Of SQL Outer Join? Syntax: SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name WHERE condition; (3) Examples Of SQL Outer Join? Customer: Orders: Example-1: SELECT Customers.CustomerName, Orders.OrderID FROM Customers FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName; Note:  The FULL OUTER

    Read More