You are on page 1of 19

LESSON – 1 (MANIPULATION)

CREATE TABLE command is used to create tables in SQL.

Here Create table is a clause. Clause performs specific task in SQL.

Example of table creation:

INSERT INTO command is used to insert new row of data in table.

SELECT statements are used to fetch data from database.

 SELECT is a clause that indicates that the statement is a query.

ALTER TABLE statement allows to add new column in a table using ADD COLUMN clause.

UPDATE statement edits row in a table.

The ALTER statement is used to modify columns. With ALTER, you can add columns, remove
them, or even modify them.

The UPDATE statement is used to modify rows. However, UPDATE can only update a row, and


cannot remove or add rows.
DELETE FROM statement deletes one or more rows from a table.

Constraints add information about how a column can be used.

1. PRIMARY KEY columnscan be used to uniquely identify the row.


2. UNIQUE columns have a different value for every row. This is similar to PRIMARY
KEY except a table can have many different UNIQUE columns.

Recap of all commands:


LESSON – 2 (QUERIES)
Queries are used to retrieve information stored in database.

AS is a keyword in SQL that allows you to rename a column or table using an alias. 

DISTINCT is used to return unique values in the output. It filters out all duplicate values in specified
column(s).

WHERE clause is used to restrict query result and obtain desired information. It basically filters out
result.

LIKE clause is used to compare similar values. It is a special operator used with WHERE clause to
search for a specific pattern in a column. Below two wildcards are used:

_ Single value.

% Multiple values
It is not possible to test for NULL values with comparison operators like = and !=.

Instead, we will have to use operators 1.) IS NULL 2.) IS NOT NULL.

BETWEEN operator is used with WHERE clause to filter the result set within a certain range.

In this statement, BETWEEN filters the result set to only include movies with names that
begin with the letter ‘A’ up to, but not including ones that begin with ‘J’.

Here between two numbers is inclusive of second number also.

AND operator is used to combine multiple conditions. It displays results when all conditions are met.

OR operator is used to combine multiple conditions. It displays results when any of condition is met.

ORDER BY clause is used to sort results for a particular column.


CASE statement allows to create different outputs in SELECT statement.

LESSON – 3 (AGGREGATE FUNCTIONS)


Some important aggregate functions used in SQL COUNT(), SUM(), MAX(), MIN(), AVG(), ROUND().

COUNT() Used to calculate how many rows are in a table.

SUM() is used to add all values in particular column.

MAX() and MIN() returns highest and lowest values in column, respectively.

AVG() is used to calculate average value of particular column.

ROUND() function rounds of the value to mentioned integer in statement.

GROUP BY() clause is used with aggregate functions to arrange identical data into groups.

The GROUP BY statement comes after any WHERE statements, but before ORDER BY or LIMIT.

HAVING() clause is used with aggregate functions. It is used to filter which groups to include and
which groups to exclude.

HAVING statement always comes after GROUP BY, but before ORDER BY and LIMIT.

LESSON – 4 (MULTIPLE TABLES)


JOIN command is used to link tables

LEFT JOIN

When the primary key for one table appears in a different table, it is called a foreign
key.
CROSS JOIN is used to combine all rows of one table with all rows of another table.

UNION is used to append one dataset on top of other.

Requirement is that both tables should have same number of columns and same data type.

WITH clause is used to combine the result of one table with other table.

WITH allows us to define one or more temporary tables that can be used in the final
query.

CASE-WHEN SQL Queries


RSS – Residual Sum of Squares

TSS – Total Sum of Squares


Types of sampling:

https://www.scribbr.com/methodology/sampling-methods/

A type I error (false-positive) occurs if an investigator rejects a null hypothesis that


is actually true in the population; a type II error (false-negative) occurs if the
investigator fails to reject a null hypothesis that is actually false in the population.

https://www.analyticsvidhya.com/blog/2016/07/deeper-regression-analysis-assumptions-plots-
solutions/
Importing libraries in Python
Pandas DataFrame dropna() Function is used to drop null values.
Tweepy python library is used for retrieving tweets.
Program for Square root of a number in python.

1. How would you replace all NaN values in a Pandas dataframe?


https://www.bestinterviewquestion.com/mysql-interview-questions

Find Nth Highest Salary using SQL


Select id, salary from Emp e1

Where N-1 = select (count(distinct salary)

From Emp e2 where e2.salary > e1.salary);

Windows Functions:

ROW_Number() Function generates unique row number for a row.

Partition By() Function: We can actually go and group records and then apply row number function
on it.
RANK() – For repetitive data RANK() function uses same unique number. It skips continuous
numbers.

DENSE_RANK() – Same as rank but does not skip continuous numbers.

Data set
Select E_name from Emp where Salary = (select max(Salary) from Emp);

Types of SQL Joins:

Inner Join

Left Join

Right Join

Full Join

Best Examples : https://learnsql.com/blog/common-sql-job-interview-questions/

https://learnsql.com/blog/common-sql-job-interview-questions/

Power BI - https://www.tutorialspoint.com/power_bi/dax_basics_in_power_bi.htm

There are two places where we write DAX:

 Calculated Column
 Calculated Measure

Let’s see what both of these stand for:

 Calculated columns are very similar to regular columns that we see in most


datasets. The difference is that calculated columns are the result of our
computations by using two or more columns or using columns from different
tables. They can be used when we want to perform row-wise calculations
 Calculated Measure, on the other hand, is similar to a calculated column.
However, they do not occupy any physical memory and their results cannot be
seen in the form of a column. We usually use this when we want to perform
dynamic computations on a group of rows or by grouping data together
https://www.analyticsvidhya.com/blog/2019/05/10-useful-data-analysis-expressions-
dax-functions-power-bi/

You might also like