SQL queries: Frequently used Sql queries  

Structured Query Language (SQL) is a particular language for refreshing, erasing, and mentioning data from databases. SQL is an ANSI and ISO standard, and it is additionally standard database Query language.

0 254 Technology | Sql Server
Thu May 16 , 2019

Here are a couple of the most significant sql inquiries which is being utilized by pretty much every developer – every one of these questions is considerable to pretty much every framework that communicates with a SQL database.

Sql Query To Create a table

Create table Student
(
StudentId int,
StudentName varchar(100),
StudentAge int,
Salary int
)

Sql Query To Insert Data Into a Table

Insert into Student(StudentId,StudentName,StudentAge,Salary) values(1,'Rahul',28,12000)
Insert into Student(StudentId,StudentName,StudentAge,Salary) values(2,'Amit',25,18000)
Insert into Student(StudentId,StudentName,StudentAge,Salary) values(3,'Arun',25,10000)
Insert into Student(StudentId,StudentName,StudentAge,Salary) values(4,'Santosh',48,22000)

SQL Query for Selecting all Columns

SELECT * FROM Student

SQL Query for Selecting single Columns

SELECT StudentId FROM Student

SQL Query for Selecting all Columns Using a Constraint

SELECT * FROM Student where StudentId=1

SQL Query for Sorted Data Using ‘Order By’

SELECT StudentId, StudentName FROM Student
WHERE StudentAge = 25 ORDER BY StudentId

SQL Query for Sorted Data Using ‘Group By’

SELECT StudentName, StudentAge FROM Student WHERE StudentAge > 10 
GROUP BY StudentAge ORDER BY StudentName

SQL Query to Count Number of Student

SELECT COUNT(StudentId) FROM Student

SQL Query to Count Number of Student

SELECT SUM(Salary)FROM Student WHERE StudentAge < 20;

SQL Query to retrive Unique Values from a table

SELECT DISTINCT StudentId FROM Student

SQL Query using TOP Clause

SELECT TOP 2 FROM Student WHERE StudentName<>NULL;

Sql Query to add column in a table

ALTER TABLE Student ADD FatherName varchar(80)

Sql Query to Update column in a table

ALTER TABLE Student alter FatherName nvarchar(50)

Sql Query to Drop a Table

DROP TABLE Student

Sql Query to replace NULL Value from a Column

SELECT ISNULL(StudentName,'Any Value You May Pass ex- N/A') as StudentName, StudentAge FROM Student




Subscribe & Get Regular Updates On Your E-mail