Author Archives: Stanislav_Panteleev

Database.Beginner.What is the purpose of DISTINCT?

✅ DISTINCT is used to: Remove duplicate rows from the result set. It ensures that the output has only unique rows — no duplicates. It compares all selected columns — if all columns in a row match, it’s considered a … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is the purpose of DISTINCT?

Database.Beginner.What is the default sort order of ORDER BY?

What is the Default Sort Order of ORDER BY? ✅ By default, ORDER BY sorts in: Ascending (ASC) order — from smallest to largest, A → Z, 0 → 9. If you don’t specify anything, this: is the same as: … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is the default sort order of ORDER BY?

Database.Beginner.How to Fetch the Top N Records in SQL ?

It depends a little on the SQL dialect (MySQL, PostgreSQL, SQL Server, etc.), but the general idea is: 1. Using LIMIT (MySQL, PostgreSQL, SQLite) ✅ Example — get top 5 employees with highest salary: ORDER BY salary DESC — sort … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.How to Fetch the Top N Records in SQL ?

Database.Beginner.What is the difference between DELETE, TRUNCATE, and DROP?

DELETE vs TRUNCATE vs DROP Command What it Does Speed Can Rollback? Affects Structure? DELETE Deletes specific rows based on WHERE condition (or all if no condition). Slow for big tables ✅ Yes (if in a transaction) ❌ No — … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is the difference between DELETE, TRUNCATE, and DROP?

Database.Beginner.Is primary key only about uniquness ?

Uniqueness: ✅ No two rows can have the same value (or same combination, for composite keys). NOT NULL: ✅ No NULLs allowed in any column that is part of the Primary Key. Every row must have a real, non-missing value … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.Is primary key only about uniquness ?

Database.Beginner.What is primary key?

What is a Composite Key? A Composite Key is a Primary Key (or sometimes a Unique Key) that is made up of two or more columns. It’s called composite because it’s combined from multiple columns to uniquely identify a row. … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is primary key?

Database.Beginner.Can i group by many columns ?

Absolutely YES! ✅ You can GROUP BY many columns — and it’s very common in real-world SQL queries! GROUP BY Many Columns — How It Works When you group by multiple columns: SQL will create a separate group for each … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.Can i group by many columns ?

Database.Beginner.What is the purpose of the GROUP BY clause?

The GROUP BY clause is used to: Group rows that have the same values in specified columns into summary rows — like totals, counts, averages, etc. ✅ It’s most commonly used with aggregate functions like: SUM() COUNT() AVG() MAX() MIN() … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is the purpose of the GROUP BY clause?

Database.Beginner.What is a VIEW in SQL?

What is a VIEW in SQL? A VIEW is a virtual table in SQL. It’s a saved SQL query that you can treat like a table when writing queries. A VIEW does not store actual data — it just stores … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What is a VIEW in SQL?

Database.Beginner.What about composite primary key and many unique constraints ?

Composite Primary Key A Primary Key doesn’t have to be just one column — it can be a combination of multiple columns. That’s called a composite primary key. ✅ Example: Here: (student_id, course_id) together uniquely identify each row. A student … Continue reading →

Posted in Без рубрики | Comments Off on Database.Beginner.What about composite primary key and many unique constraints ?