SQL Complete Notes
SQL Complete Notes
INNER JOIN:
FROM Students
LEFT JOIN:
FROM Students
RIGHT JOIN:
FROM Students
FROM Students
Output Example:
| Name | DeptName |
|--------|--------------|
| Ravi | Electronics |
| Meena | NULL |
| NULL | Mechanical |
Query:
FROM Students;
Sample Output:
|-------------------|----------------|-----------|--------------|--------|----------|
|4 |5 | 82 | 20.5 | 22 | 19 |
Query:
FROM Students S
GROUP BY D.DeptName;
Output:
| DeptName | Num_Students |
|---------------|--------------|
| Computer Sci | 3 |
| Electronics | 1 |
| Mechanical |1 |
Definition: GROUP BY groups rows to apply aggregate functions. HAVING filters the result groups.
Syntax:
FROM table
GROUP BY column
HAVING condition;
Example:
FROM Students
GROUP BY DeptID
Output:
| DeptID | AvgMarks |
|--------|----------|
| 101 | 87.67 |
Syntax:
Example:
Syntax:
Example:
FROM Students;
Output:
| Name | Contact |
|--------|--------------|
| Asha | 9876543210 |
| Ravi | No Phone |
| Meena | 8899001122 |