CASE Statement

🔹 What is a CASE Statement? A CASE statement lets you apply conditional logic in SQL queries — kind of like an if-else in programming languages. Basic Syntax: CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... ELSE resultN END CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... ELSE resultN END…

0 Comments

UNION, INTERSECT, EXCEPT

SQL supports combining results from two or more queries (with the same number of columns and compatible data types) using set operators. The main ones are: 1. UNION Combines the results of two queries. Removes duplicates by default. Columns in both queries must have the same number and compatible data types. SELECT city FROM…

0 Comments

String & Date Functions

🔹 String Functions in SQL These are used to manipulate text values (CHAR, VARCHAR, etc.). 1. UPPER() – Convert to uppercase SELECT UPPER('hello world') AS UpperCase; -- Output: HELLO WORLD SELECT UPPER('hello world') AS UpperCase; -- Output: HELLO WORLD 2. LOWER() – Convert to lowercase SELECT LOWER('HELLO SQL') AS LowerCase; -- Output: hello sql…

0 Comments

Primary Keys & Foreign Keys

🔑 Primary Key A Primary Key is a column (or set of columns) that uniquely identifies each row in a table. Rules: Must be unique. Cannot be NULL. A table can have only one primary key (but it can consist of multiple columns = composite key). Example: CREATE TABLE Students ( StudentID INT PRIMARY…

0 Comments

Subqueries in SQL

🔹 What is a Subquery? A subquery is a query inside another SQL query.It is often used in the WHERE, FROM, or SELECT clause to provide intermediate results. 🔹 Types of Subqueries Single-row subquery → returns only one value Multi-row subquery → returns multiple values Nested subquery in SELECT or FROM → used as…

0 Comments

SQL Joins

We’ll use two simple tables as reference: Table: Employees EmpIDNameDeptID1Alice102Bob203Charlie304DavidNULL Table: Departments DeptIDDeptName10HR20IT30Finance40Marketing 1. INNER JOIN Returns only the matching rows between two tables. SELECT e.Name, d.DeptName FROM Employees e INNER JOIN Departments d ON e.DeptID = d.DeptID; SELECT e.Name, d.DeptName FROM Employees e INNER JOIN Departments d ON e.DeptID = d.DeptID; Result: NameDeptNameAliceHRBobITCharlieFinance…

0 Comments

SQL grouping concepts

1. GROUP BY GROUP BY is used to group rows that have the same values in one or more columns. It’s often used with aggregate functions like COUNT(), SUM(), AVG(), MAX(), MIN(). Example: SELECT department, COUNT(*) AS employee_count FROM employees GROUP BY department; SELECT department, COUNT(*) AS employee_count FROM employees GROUP BY department; 👉…

0 Comments

Mocha

Mocha is a JavaScript test framework running on Node.js, commonly used for testing applications (both frontend and backend). It provides a structure for writing unit tests and integration tests, making sure your code behaves as expected. Mocha doesn’t come with an assertion library by default, but it works well with popular ones like Chai,…

0 Comments

Jasmine and Karma

🔹 What is Jasmine? Jasmine is a behavior-driven development (BDD) testing framework for JavaScript. It’s mainly used to test JavaScript code (both frontend and backend). It provides functions like describe(), it(), and expect() to write human-readable tests. No need for DOM or browser—it can run independently. 🔹 What is Karma? Karma is a test…

0 Comments

Jest

Jest is a JavaScript testing framework maintained by Meta (Facebook). It’s widely used for testing React applications, but it works with any JavaScript/TypeScript project. It provides features like: Unit testing: testing small pieces of code (functions, components). Snapshot testing: ensuring UI doesn’t change unexpectedly. Mocking: simulating functions, APIs, or modules. Zero configuration: works out…

0 Comments

End of content

No more pages to load