60% found this document useful (5 votes)
60K views5 pages

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

The document demonstrates various SQL queries: 1) It creates a student table with attributes like student ID, name, gender, section, stream, and marks. 2) It inserts details of 11 students into the student table. 3) It deletes details of a student with ID 11 from the table. 4) It selects details of students with marks more than 80. 5) It finds the min, max, sum and average of marks in the student table. 6) It orders the student ID and marks table in descending order of marks. 7) It creates a consumer table and inserts records, then uses group by to find the total number of customers from each country.

Uploaded by

zahir khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
60% found this document useful (5 votes)
60K views5 pages

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

The document demonstrates various SQL queries: 1) It creates a student table with attributes like student ID, name, gender, section, stream, and marks. 2) It inserts details of 11 students into the student table. 3) It deletes details of a student with ID 11 from the table. 4) It selects details of students with marks more than 80. 5) It finds the min, max, sum and average of marks in the student table. 6) It orders the student ID and marks table in descending order of marks. 7) It creates a consumer table and inserts records, then uses group by to find the total number of customers from each country.

Uploaded by

zahir khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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