0% found this document useful (0 votes)
17 views2 pages

SQL and Python Interview Questions Guide

The document outlines basic interview questions related to SQL and Python, covering topics such as SQL commands, joins, aggregate functions, and Python data types. It includes definitions and differences between key concepts like primary keys, foreign keys, lists, and tuples. The questions are structured to assess foundational knowledge in both SQL and Python programming.

Uploaded by

Nishu Goud
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

SQL and Python Interview Questions Guide

The document outlines basic interview questions related to SQL and Python, covering topics such as SQL commands, joins, aggregate functions, and Python data types. It includes definitions and differences between key concepts like primary keys, foreign keys, lists, and tuples. The questions are structured to assess foundational knowledge in both SQL and Python programming.

Uploaded by

Nishu Goud
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL and Python Basic Interview Questions

1. SQL Basics

- What is SQL?

- What is a database?

- What is a table in SQL?

- What are rows and columns in a table?

- What is the difference between SQL and MySQL?

- What is a primary key?

- What is a foreign key?

2. SQL Commands

- What are the different types of SQL commands?

- What is the difference between DDL, DML, and DCL commands?

- What does the CREATE command do?

- What does the ALTER command do?

- What does the DROP command do?

- What does the INSERT command do?

- What does the UPDATE command do?

- What does the DELETE command do?

- What is the TRUNCATE command?

3. SELECT and Filtering

- What is the use of the SELECT statement?

- How do you filter records in SQL?

- What is the WHERE clause used for?

- What is the ORDER BY clause?

- What is the GROUP BY clause?

- What is the HAVING clause?

4. JOINS

- Inner Join
- Full Join

- Left Join

- Right Join

5. Aggregations and Functions

- What are aggregate functions in SQL?

- Name a few aggregate functions.

- What is the difference between COUNT(*) and COUNT(column_name)?

- How do you find the average salary of employees?

- What is the purpose of the SUM() function?

- What is the MAX() and MIN() function used for?

- What is the difference between aggregate and scalar functions?

- What is the use of the CONCAT() function?

- What is the use of the LENGTH() function?

- What is the purpose of the UPPER() and LOWER() functions?

- Explain IN, BETWEEN, LIKE, NULL, and DISTINCT keywords.

Python Basic Questions

- What is Python?

- What are the key features of Python?

- What are Python data types?

- What is the difference between a list and a tuple?

- What is a dictionary in Python?

- What is the difference between mutable and immutable data types?

- What are variables in Python?

- What is the difference between local and global variables?

Common questions

Powered by AI

SQL commands can be broadly categorized into DDL (Data Definition Language), DML (Data Manipulation Language), and DCL (Data Control Language). DDL commands, such as CREATE, ALTER, and DROP, are used to define and manage database structures like tables and schemas. DML commands, like INSERT, UPDATE, and DELETE, are used for manipulating data within those structures. DCL commands, such as GRANT and REVOKE, handle permissions and access controls within the database .

Python dictionaries store data as key-value pairs, allowing for constant time complexity when retrieving, adding, or deleting elements using keys. Unlike lists, which are ordered collections of items accessed by index, and tuples, which are immutable sequences, dictionaries are unordered and mutable. This makes dictionaries ideal for scenarios where it is necessary to quickly locate data without relying on sequential access .

Python is considered versatile due to its readability, simplicity, and extensive standard library. Its key features include dynamic typing, interpretability, and a large collection of third-party modules, which allow for rapid development and integration across various domains such as web development, data analysis, and artificial intelligence. Python’s cross-platform nature and active community support further enhance its versatility .

The WHERE clause is used to filter rows before any groupings are made in the result set, typically based on conditions on individual records. The HAVING clause, however, is used to filter records after they have been grouped by the GROUP BY clause, allowing for conditions to be applied to aggregated data. Thus, WHERE is for raw data filtering, while HAVING is for aggregated data filtering .

Aggregate functions operate on a set of values and return a single value, such as SUM(), AVG(), COUNT(), MAX(), and MIN(), and are typically used with GROUP BY clauses to perform operations on groups of rows. Scalar functions, on the other hand, operate on individual values and return a single value for each input, such as UPPER(), LOWER(), and LENGTH(). They are often used for manipulating data in SELECT statements .

ORDER BY sorts the result set based on specified column(s), allowing for either ascending or descending sorting. GROUP BY aggregates data based on selected columns, allowing for aggregate functions like SUM() and COUNT(). WHERE filters the dataset before any aggregation or sorting, providing conditional logic to exclude certain rows. Together, these clauses help mold data retrieval from filtering raw data to presenting aggregated and ordered information .

An inner join retrieves records that have matching values in both tables being joined. It excludes records without corresponding matches. In contrast, a left join includes all records from the left table and the matched records from the right, a right join does the opposite, and a full join includes all records when there is a match in either table. Inner joins are often used when you only need records with exact matches across both tables .

Aggregate functions perform operations on multiple values to return a summary, such as COUNT() for counting rows, SUM() for computing totals, and AVG() for calculating averages. These functions are essential in generating reports, such as finding total sales, average salary, or the count of employees in a department. Aggregate functions allow for data analysis and insights from large data sets .

SQL is a standard language for querying and managing data in a relational database, whereas MySQL is a specific relational database management system (RDBMS) that uses SQL as its language. MySQL provides additional functionalities and is designed to efficiently store, modify, and retrieve data .

A primary key is a unique identifier for each record in a table, ensuring that no two rows can have the same primary key value. A foreign key, on the other hand, is a field in a table that links to the primary key of another table, establishing a relationship between tables. These keys help enforce referential integrity, ensuring that data is consistent across related tables .

You might also like