mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-19 23:53:24 +02:00
Fix syntax issue
This commit is contained in:
@@ -2,21 +2,14 @@ Function scope refers to the scope of variables defined within a function. You c
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function myStudyPlan() {
|
function myStudyPlan() {
|
||||||
|
var studyPlanOne = "Top JavaScript interview questions for web developers";
|
||||||
|
let studyPlanTwo = "Top JavaScript interview questions for web developers";
|
||||||
|
const studyPlanThree = "Top JavaScript interview questions for web developers";
|
||||||
|
|
||||||
var studyPlanOne = "Top JavaScript interview questions for web developers";
|
console.log(studyPlanOne);
|
||||||
|
console.log(studyPlanTwo);
|
||||||
let studyPlanTwo = "Top JavaScript interview questions for web developers";
|
console.log(studyPlanThree);
|
||||||
|
|
||||||
const studyPlanThree = "Top JavaScript interview questions for web developers";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(studyPlanOne);
|
|
||||||
|
|
||||||
console.log(studyPlanTwo);
|
|
||||||
|
|
||||||
console.log(studyPlanThree);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myStudyPlan(); // Calls the function
|
myStudyPlan(); // Calls the function
|
||||||
|
```
|
32
src/data/question-groups/sql/content/where-vs-having.md
Normal file
32
src/data/question-groups/sql/content/where-vs-having.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
You use **WHERE** for filtering rows before applying any grouping or aggregation.
|
||||||
|
The code snippet below illustrates the use of **WHERE**. It filters the `Users` table for rows where the `Age` is greater than 18.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM Users
|
||||||
|
WHERE Age > 18;
|
||||||
|
```
|
||||||
|
|
||||||
|
The result of the query is similar to the table below.
|
||||||
|
|
||||||
|
| userId | firstName | lastName | age |
|
||||||
|
| ------ | --------- | -------- | --- |
|
||||||
|
| 1 | John | Doe | 30 |
|
||||||
|
| 2 | Jane | Don | 31 |
|
||||||
|
| 3 | Will | Liam | 25 |
|
||||||
|
| 4 | Wade | Great | 32 |
|
||||||
|
| 5 | Peter | Smith | 27 |
|
||||||
|
|
||||||
|
On the other hand, you use **HAVING** to filter groups after performing grouping and aggregation. You apply it to the result of aggregate functions, and it is mostly used with the **GROUP BY** clause.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT FirstName, Age FROM Users
|
||||||
|
GROUP BY FirstName, Age
|
||||||
|
HAVING Age > 30;
|
||||||
|
```
|
||||||
|
|
||||||
|
The code above selects the `FirstName` and `Age` columns, then groups by the `FirstName` and `Age`, and finally gets entries with age greater than 30. The result of the query looks like this:
|
||||||
|
|
||||||
|
| firstName | age |
|
||||||
|
| --------- | --- |
|
||||||
|
| Wade | 32 |
|
||||||
|
| Jane | 31 |
|
Reference in New Issue
Block a user