CREATING A TABLE

CREATE TABLE EmployeeSalary
(EmployeeID int,
JobTitle varchar(50),
Salary int)

SELECTING TOP ROWS FROM A TABLE

SELECT TOP(1000) [EmployeeID], [FirstName], [LastName],[Age],[Gender]
FROM [SQL].dbo.[EmployeeDemographics]

INSERTING DATA INTO TABLE

INSERT INTO EmployeeDemographics VALUES
( 1001, 'Ishita', 'Tandon, 20, 'Female'),
(1002, 'Ish', 'Tan', 31, 'Female')

PULLING DATA FROM ALL COLUMNS FROM A TABLE USING SELECT STATEMENT

SELECT *
FROM EmployeeDemographics

PULLING DATA FROM A PARTICULAR COLUMN FROM A TABLE USING A SELECT STATEMENT

SELECT FirstName
FROM EmployeeDemographics

PULLING DATA FROM THE TOP 5 ROWS USING A SELECT STATEMENT

SELECT TOP 5 *
FROM EmployeeDemographics

PULLING ONLY UNIQUE VALUES OF A SPECIFIC COLUMN

SELECT DISTINCT(FirstName)
FROM EmployeeDemographics

COUNTING THE NON-NULL VALUES IN A COLUMN

SELECT COUNT(FirstName) AS LastNameCount
FROM EmployeeDemographics

FINDING MAXIMUM AND MINIMUM VALUES IN A COLUMN

SELECT MIN(Salary), MAX(Salary), AVG(Salary)
FROM EmployeeSalary

USING WHERE STATEMENT TO PULL OUT A PARTICULAR ENTRY

SELECT *
FROM EmployeeDemographics
WHERE FirstName= 'Ish' AND Age>=20 AND LastName LIKE 'Ta%'

Other operators that can be used to search a particular entry are =,<>,<,>, AND, OR, LIKE, NULL, NOT NULL, IN

USING GROUP BY STATEMENT TO GROUP DATA IN A COLUMN

SELECT Gender, COUNT(Gender)AS CountGender
FROM EmployeeDemographics
GROUP BY Gender
ORDER BY CountGender DESC

Order by is ascending by default

USING ORDER BY STATEMENT TO DISPLAY DATA IN CERTAIN ORDER

SELECT *
FROM EmployeeDemographics
ORDER BY Age

Hi, My name is Ishita. I am an electrical engineering undergrad at the National Institute of Technology. I took the initiative to write a blog because when I started learning programming I faced obstacles finding the right sources. Now I want to share my knowledge with everyone stepping into learning programming for Data Science to make it easier for them. Honestly, I am no expert but feel free to join me along my journey as we both learn together. You can connect with me on LinkedIn.

https://www.linkedin.com/in/ishita-tandon-247a521ab/