From 4931ba060fa475a96bdd605123d605d24a490711 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 15 Aug 2025 21:24:05 +0100 Subject: [PATCH] Fix syntax issue --- .../javascript/content/function-scope.md | 23 +++++-------- .../sql/content/where-vs-having.md | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 src/data/question-groups/sql/content/where-vs-having.md diff --git a/src/data/question-groups/javascript/content/function-scope.md b/src/data/question-groups/javascript/content/function-scope.md index 25738e7d5..f621ec3c0 100644 --- a/src/data/question-groups/javascript/content/function-scope.md +++ b/src/data/question-groups/javascript/content/function-scope.md @@ -2,21 +2,14 @@ Function scope refers to the scope of variables defined within a function. You c ```javascript 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"; - -let studyPlanTwo = "Top JavaScript interview questions for web developers"; - -const studyPlanThree = "Top JavaScript interview questions for web developers"; - - - -console.log(studyPlanOne); - -console.log(studyPlanTwo); - -console.log(studyPlanThree); - + console.log(studyPlanOne); + console.log(studyPlanTwo); + console.log(studyPlanThree); } -myStudyPlan(); // Calls the function \ No newline at end of file +myStudyPlan(); // Calls the function +``` \ No newline at end of file diff --git a/src/data/question-groups/sql/content/where-vs-having.md b/src/data/question-groups/sql/content/where-vs-having.md new file mode 100644 index 000000000..7cd0b68e7 --- /dev/null +++ b/src/data/question-groups/sql/content/where-vs-having.md @@ -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 | \ No newline at end of file