*SQL Interview Questions which can be asked in a Data Analyst Interview.*
1️⃣ What is difference between Primary key and Unique key?
◼Primary key- A column or set of columns which uniquely identifies each record in a table. It can't contain null values and only one primary key
can exist in a table.
◼Unique key-Similar to primary key it also uniquely identifies each record in a table and can contain null values.Multiple Unique key can exist in a table.
2️⃣ What is a Candidate key?
◼A key or set of keys that uniquely identifies each record in a table.It is a combination of Primary and Alternate key.
3️⃣ What is a Constraint?
◼Specific rule or limit that we define in our table. E.g - NOT NULL,AUTO INCREMENT
4️⃣ Can you differentiate between TRUNCATE and DELETE?
◼TRUNCATE is a DDL command. It deletes the entire data from a table but preserves the structure of table.It doesn't deletes the data row by row hence faster than DELETE command, while DELETE is a DML command and it deletes the entire data based on specified condition else deletes the entire data,also it deletes the data row by row hence slower than TRUNCATE command.
5️⃣ What is difference between 'View' and 'Stored Procedure'?
◼A View is a virtual table that gets data from the base table .It is basically a Select statement,while Stored Procedure is a sql statement or set of sql statement stored on database server.
6️⃣ What is difference between a Common Table Expression and temporary table?
◼CTE is a temporary result set that is defined within execution scope of a single SELECT ,DELETE,UPDATE statement while temporary table is stored in TempDB and gets deleted once the session expires.
7️⃣ Differentiate between a clustered index and a non-clustered index?
◼ A clustered index determines physical ordering of data in a table and a table can have only one clustered index while a non-clustered index is analogous to index of a book where index is stored at one place and data at other place and index will have pointers to storage location of the data,a table can have more than one non-clustered index.
8️⃣ Explain triggers ?
◼They are sql codes which are automatically executed in response to certain events on a table.They are used to maintain integrity of data.
1️⃣ What is difference between Primary key and Unique key?
◼Primary key- A column or set of columns which uniquely identifies each record in a table. It can't contain null values and only one primary key
can exist in a table.
◼Unique key-Similar to primary key it also uniquely identifies each record in a table and can contain null values.Multiple Unique key can exist in a table.
2️⃣ What is a Candidate key?
◼A key or set of keys that uniquely identifies each record in a table.It is a combination of Primary and Alternate key.
3️⃣ What is a Constraint?
◼Specific rule or limit that we define in our table. E.g - NOT NULL,AUTO INCREMENT
4️⃣ Can you differentiate between TRUNCATE and DELETE?
◼TRUNCATE is a DDL command. It deletes the entire data from a table but preserves the structure of table.It doesn't deletes the data row by row hence faster than DELETE command, while DELETE is a DML command and it deletes the entire data based on specified condition else deletes the entire data,also it deletes the data row by row hence slower than TRUNCATE command.
5️⃣ What is difference between 'View' and 'Stored Procedure'?
◼A View is a virtual table that gets data from the base table .It is basically a Select statement,while Stored Procedure is a sql statement or set of sql statement stored on database server.
6️⃣ What is difference between a Common Table Expression and temporary table?
◼CTE is a temporary result set that is defined within execution scope of a single SELECT ,DELETE,UPDATE statement while temporary table is stored in TempDB and gets deleted once the session expires.
7️⃣ Differentiate between a clustered index and a non-clustered index?
◼ A clustered index determines physical ordering of data in a table and a table can have only one clustered index while a non-clustered index is analogous to index of a book where index is stored at one place and data at other place and index will have pointers to storage location of the data,a table can have more than one non-clustered index.
8️⃣ Explain triggers ?
◼They are sql codes which are automatically executed in response to certain events on a table.They are used to maintain integrity of data.
👍23❤3👏1
Quick Recap of SQL Concepts
1️⃣ FROM clause: Specifies the tables from which data will be retrieved.
2️⃣ WHERE clause: Filters rows based on specified conditions.
3️⃣ GROUP BY clause: Groups rows that have the same values into summary rows.
4️⃣ HAVING clause: Filters groups based on specified conditions.
5️⃣ SELECT clause: Specifies the columns to be retrieved.
6️⃣ WINDOW functions: Functions that perform calculations across a set of table rows.
7️⃣ AGGREGATE functions: Functions like COUNT, SUM, AVG that perform calculations on a set of values.
8️⃣ UNION / UNION ALL: Combines the result sets of multiple SELECT statements.
9️⃣ ORDER BY clause: Sorts the result set based on specified columns.
🔟 LIMIT / OFFSET (or FETCH / OFFSET in some databases): Controls the number of rows returned and starting point for retrieval.
1️⃣ FROM clause: Specifies the tables from which data will be retrieved.
2️⃣ WHERE clause: Filters rows based on specified conditions.
3️⃣ GROUP BY clause: Groups rows that have the same values into summary rows.
4️⃣ HAVING clause: Filters groups based on specified conditions.
5️⃣ SELECT clause: Specifies the columns to be retrieved.
6️⃣ WINDOW functions: Functions that perform calculations across a set of table rows.
7️⃣ AGGREGATE functions: Functions like COUNT, SUM, AVG that perform calculations on a set of values.
8️⃣ UNION / UNION ALL: Combines the result sets of multiple SELECT statements.
9️⃣ ORDER BY clause: Sorts the result set based on specified columns.
🔟 LIMIT / OFFSET (or FETCH / OFFSET in some databases): Controls the number of rows returned and starting point for retrieval.
👍11
SQL, or Structured Query Language, is a domain-specific language used to manage and manipulate relational databases. Here's a brief A-Z overview by @sqlanalyst
A - Aggregate Functions: Functions like COUNT, SUM, AVG, MIN, and MAX used to perform operations on data in a database.
B - BETWEEN: A SQL operator used to filter results within a specific range.
C - CREATE TABLE: SQL statement for creating a new table in a database.
D - DELETE: SQL statement used to delete records from a table.
E - EXISTS: SQL operator used in a subquery to test if a specified condition exists.
F - FOREIGN KEY: A field in a database table that is a primary key in another table, establishing a link between the two tables.
G - GROUP BY: SQL clause used to group rows that have the same values in specified columns.
H - HAVING: SQL clause used in combination with GROUP BY to filter the results.
I - INNER JOIN: SQL clause used to combine rows from two or more tables based on a related column between them.
J - JOIN: Combines rows from two or more tables based on a related column.
K - KEY: A field or set of fields in a database table that uniquely identifies each record.
L - LIKE: SQL operator used in a WHERE clause to search for a specified pattern in a column.
M - MODIFY: SQL command used to modify an existing database table.
N - NULL: Represents missing or undefined data in a database.
O - ORDER BY: SQL clause used to sort the result set in ascending or descending order.
P - PRIMARY KEY: A field in a table that uniquely identifies each record in that table.
Q - QUERY: A request for data from a database using SQL.
R - ROLLBACK: SQL command used to undo transactions that have not been saved to the database.
S - SELECT: SQL statement used to query the database and retrieve data.
T - TRUNCATE: SQL command used to delete all records from a table without logging individual row deletions.
U - UPDATE: SQL statement used to modify the existing records in a table.
V - VIEW: A virtual table based on the result of a SELECT query.
W - WHERE: SQL clause used to filter the results of a query based on a specified condition.
X - (E)XISTS: Used in conjunction with SELECT to test the existence of rows returned by a subquery.
Z - ZERO: Represents the absence of a value in numeric fields or the initial state of boolean fields.
A - Aggregate Functions: Functions like COUNT, SUM, AVG, MIN, and MAX used to perform operations on data in a database.
B - BETWEEN: A SQL operator used to filter results within a specific range.
C - CREATE TABLE: SQL statement for creating a new table in a database.
D - DELETE: SQL statement used to delete records from a table.
E - EXISTS: SQL operator used in a subquery to test if a specified condition exists.
F - FOREIGN KEY: A field in a database table that is a primary key in another table, establishing a link between the two tables.
G - GROUP BY: SQL clause used to group rows that have the same values in specified columns.
H - HAVING: SQL clause used in combination with GROUP BY to filter the results.
I - INNER JOIN: SQL clause used to combine rows from two or more tables based on a related column between them.
J - JOIN: Combines rows from two or more tables based on a related column.
K - KEY: A field or set of fields in a database table that uniquely identifies each record.
L - LIKE: SQL operator used in a WHERE clause to search for a specified pattern in a column.
M - MODIFY: SQL command used to modify an existing database table.
N - NULL: Represents missing or undefined data in a database.
O - ORDER BY: SQL clause used to sort the result set in ascending or descending order.
P - PRIMARY KEY: A field in a table that uniquely identifies each record in that table.
Q - QUERY: A request for data from a database using SQL.
R - ROLLBACK: SQL command used to undo transactions that have not been saved to the database.
S - SELECT: SQL statement used to query the database and retrieve data.
T - TRUNCATE: SQL command used to delete all records from a table without logging individual row deletions.
U - UPDATE: SQL statement used to modify the existing records in a table.
V - VIEW: A virtual table based on the result of a SELECT query.
W - WHERE: SQL clause used to filter the results of a query based on a specified condition.
X - (E)XISTS: Used in conjunction with SELECT to test the existence of rows returned by a subquery.
Z - ZERO: Represents the absence of a value in numeric fields or the initial state of boolean fields.
👍40
Complete SQL Mastery 🤯🤯 Just Free Of Cost!!
👇👇
https://www.linkedin.com/posts/sql-analysts_sql-dataanalytics-activity-7135263158708883457-k0V6?utm_source=share&utm_medium=member_android
Like and Comment 'SQL' on this post :)
👇👇
https://www.linkedin.com/posts/sql-analysts_sql-dataanalytics-activity-7135263158708883457-k0V6?utm_source=share&utm_medium=member_android
Like and Comment 'SQL' on this post :)
👍11
👍2
This channels is for Programmers, Coders, Software Engineers.
0- Python
1- Data Science
2- Machine Learning
3- Data Visualization
4- Artificial Intelligence
5- Data Analysis
6- Statistics
7- Deep Learning
8- programming Languages
✅ Free Courses with Certificate:
https://t.me/free4unow_backup
0- Python
1- Data Science
2- Machine Learning
3- Data Visualization
4- Artificial Intelligence
5- Data Analysis
6- Statistics
7- Deep Learning
8- programming Languages
✅ Free Courses with Certificate:
https://t.me/free4unow_backup
👍5❤3
👍9
👍11
Understanding CTEs in SQL
A Common Table Expression (CTE) is a temporary result set that you can refer to within a SELECT, INSERT, UPDATE, or DELETE statement. It provides better readability and can be thought of as defining a temporary view for just one query.
A Common Table Expression (CTE) is a temporary result set that you can refer to within a SELECT, INSERT, UPDATE, or DELETE statement. It provides better readability and can be thought of as defining a temporary view for just one query.
👍20
Checklist to become data analyst
👇👇
https://www.linkedin.com/posts/sql-analysts_dataanalytics-sql-sqlqueries-activity-7147557393692889089--c1z?utm_source=share&utm_medium=member_android
👇👇
https://www.linkedin.com/posts/sql-analysts_dataanalytics-sql-sqlqueries-activity-7147557393692889089--c1z?utm_source=share&utm_medium=member_android
👍5
Data Analytics using SQL & Excel
👇👇
https://www.linkedin.com/posts/sql-analysts_dataanalytics-sql-dataanalysis-activity-7148654081153167360-CUyH?utm_source=share&utm_medium=member_android
👇👇
https://www.linkedin.com/posts/sql-analysts_dataanalytics-sql-dataanalysis-activity-7148654081153167360-CUyH?utm_source=share&utm_medium=member_android
👍11
Hey 👋
Here you can access Resources for SQL & Excel❤️🔥👇
https://dataanalysts.gumroad.com/l/Sql?a=363448787
◾How to get it:
1. Click on the link
2. Enter the amount you like [Can be 0 as well :) ]
3. Click the 'I Want This' Button
4. Enter your email and get it delivered!
I'd appreciate it if you could give it a 5 star when you download it.
Join for more: https://t.me/sqlspecialist
Thanks 😊
Here you can access Resources for SQL & Excel❤️🔥👇
https://dataanalysts.gumroad.com/l/Sql?a=363448787
◾How to get it:
1. Click on the link
2. Enter the amount you like [Can be 0 as well :) ]
3. Click the 'I Want This' Button
4. Enter your email and get it delivered!
I'd appreciate it if you could give it a 5 star when you download it.
Join for more: https://t.me/sqlspecialist
Thanks 😊
👍18❤1
Forwarded from Data Analysis Books | Python | SQL | Excel | Artificial Intelligence | Power BI | Tableau | AI Resources
SQL with Practice Exercises
👇👇
https://www.linkedin.com/posts/sql-analysts_sql-with-practice-questions-activity-7155766234553237504-a-4K?utm_source=share&utm_medium=member_android
👇👇
https://www.linkedin.com/posts/sql-analysts_sql-with-practice-questions-activity-7155766234553237504-a-4K?utm_source=share&utm_medium=member_android
👍13