Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free
For collaborations: @love_data
Post #4028
4.59K
SQL 𝗢𝗿𝗱𝗲𝗿 𝗢𝗳 𝗘𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻 ↓
1 → FROM (Tables selected).
2 → WHERE (Filters applied).
3 → GROUP BY (Rows grouped).
4 → HAVING (Filter on grouped data).
5 → SELECT (Columns selected).
6 → ORDER BY (Sort the data).
7 → LIMIT (Restrict number of rows).
𝗖𝗼𝗺𝗺𝗼𝗻 𝗤𝘂𝗲𝗿𝗶𝗲𝘀 𝗧𝗼 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 ↓
↬ Find the second-highest salary:
SELECT MAX(Salary) FROM Employees WHERE Salary < (SELECT MAX(Salary) FROM Employees);
↬ Find duplicate records:
SELECT Name, COUNT(*)
FROM Emp
GROUP BY Name
HAVING COUNT(*) > 1;
1 → FROM (Tables selected).
2 → WHERE (Filters applied).
3 → GROUP BY (Rows grouped).
4 → HAVING (Filter on grouped data).
5 → SELECT (Columns selected).
6 → ORDER BY (Sort the data).
7 → LIMIT (Restrict number of rows).
𝗖𝗼𝗺𝗺𝗼𝗻 𝗤𝘂𝗲𝗿𝗶𝗲𝘀 𝗧𝗼 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 ↓
↬ Find the second-highest salary:
SELECT MAX(Salary) FROM Employees WHERE Salary < (SELECT MAX(Salary) FROM Employees);
↬ Find duplicate records:
SELECT Name, COUNT(*)
FROM Emp
GROUP BY Name
HAVING COUNT(*) > 1;
- ❤ 6
- 👍 3








