Write a SQL query to create a table Student

How to create a database Student. 

Solution : –

Create database Student;

Output :- 

– > Select Database

use Student ;

How to create table Student?

Solution :- 

Create table Student
(
No int primary key,
Name varchar(50),
age int,
department varchar(50),
DOA date,
fee int,
gender varchar(6)
);

Output :- 

->Insert value in the table Student.

Solution :-

insert into Student values(1,’Piyush’,24,’Computer’,’1997-01-10′,120,’Male’);
insert into Student values(2,’Shivam’,21,’History’,’1998-03-24′,200,’Male’);
insert into Student values(3,’Sudha’,22,’Hindi’,’1996-02-12′,300,’Female’);
insert into Student values(4,’Surya’,25,’History’,’1999-07-01′,400,’Male’);
insert into Student values(5,’Rohit’,22,’Hindi’,’1997-09-05′,250,’Male’);
insert into Student values(6,’Mohit’,30,’History’,’1998-06-27′,300,’Male’);
insert into Student values(7,’Sneha’,34,’Computer’,’1997-02-25′,210,’Female’);
insert into Student values(8,’Yash’,23,’Hindi’,’1997-07-31′,200,’Male’);

Output :- 

To show all information about the students of History Department.

Solution :- 

-> Select * from student where department = “history”;

Output :- 

To list the name of female students who are in Hindi departments.

Solution :- 

Select * from student where Department = “Hindi” and Gender=”Female”;

Output :- 

To list the names of all students with their date of admission in ascending order.

Solution :- 

Select * from student order by DOA;

Output :- 

To display student’s name,fee,age for male students only.

Solution :- 

Select name , fee, age from student where gender=”Male”;

Output :- 

To count the number of the students with age > 23.

Solution :-

Select count(*) from Student where age > 23;

Output :-