1) Create A Student Table With Student - Id, Name and Marks As Attributes Where Student - Id Is Primary Key SQL Create Table Student

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1)Create a student table with student_id, name and marks as attributes where student_id is

primary key SQL>CREATE TABLE STUDENT

SQL> CREATE TABLE students

ID int primary key, NAME varchar(20) ,

GENDER varchar(1),SECTION varchar(1),

STREAM varchar(10),MARKS int

);

2)Insert the details of a new student in the above table

SQL>INSERT INTO students VALUES (1, 'Rohit','M','C','CEC','74');

SQL>INSERT INTO students VALUES (2, 'Janani','F','A','MPC','85');

SQL>INSERT INTO students VALUES (3, 'Ronit','M','B','BiPC','96');

SQL>INSERT INTO students VALUES (4, 'Akshara','F','B','BiPC','98');

SQL>INSERT INTO students VALUES (5, 'Karthik','M','D','MEC','81');

SQL>INSERT INTO students VALUES (6, 'Prakash','M','C','CEC','91');

SQL>INSERT INTO students VALUES (7, 'Janaki','F','E','HEC','85');

SQL>INSERT INTO students VALUES (8, 'Abhay','M','A','MPC','56');

SQL>INSERT INTO students VALUES (9, 'Akhil','M','D', 'MEC','72');

SQL>INSERT INTO students VALUES (10, 'Vishal','M', 'E','HEC','69');

SQL>INSERT INTO students VALUES (11, 'Shrilata','F', 'C','CEC','34');


3) Delete the details of a student in the above table;

SQL>SELECT * FROM students;

SQL>DELETE FROM students WHERE ID=11;


4)Use the select command to get the details of the students with marks more than 80

SQL> SELECT * FROM STUDENT WHERE MARKS>80;

5) Find the min, max, sum, and average of the marks in a student marks table

SQL>SELECT min(MARKS),max(MARKS),sum(MARKS) FROM students;

6) Write a SQL query to order the (student ID, marks) table in descending order of the marks

SQL>SELECT * FROM students ORDER BY MARKS desc;


7) Find the total number of customers from each country in the table (customer ID, customer
Name, country) using group by

SQL>CREATE TABLE CONSUMER

(Customer_ID int ,

Customer_Name VARCHAR(15),

country VARCHAR(15)

);

SQL>insert into CONSUMER values(1,'Khusha','India');

SQL>insert into CONSUMER values(2,'Kajal','Nepal') ;

SQL>insert into CONSUMER values(3,'Diya','India');

SQL>insert into CONSUMER values(4,'Rahul','Nepal');

SQL>insert into CONSUMER values(5,'Neha','Sri Lanka');

SQL>insert into CONSUMER values(6,'Dhruv','Sri Lanka');

SQL>SELECT * FROM CONSUMER;

SQL>SELECT country, count(*) from CONSUMER GROUP BY country;

You might also like