0% found this document useful (0 votes)
3 views

sql

The document contains SQL queries for creating and managing two tables: 'student' and 'result', with appropriate constraints. It includes sample data for both tables and various queries to retrieve specific information such as total marks, city-wise student counts, and students' names based on certain conditions. Additionally, it demonstrates how to update the 'result' table to include a total score derived from individual marks.

Uploaded by

22bca04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

sql

The document contains SQL queries for creating and managing two tables: 'student' and 'result', with appropriate constraints. It includes sample data for both tables and various queries to retrieve specific information such as total marks, city-wise student counts, and students' names based on certain conditions. Additionally, it demonstrates how to update the 'result' table to include a total score derived from individual marks.

Uploaded by

22bca04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

sql query

Ques ons:-
student(roll_no,name,city,pin_code,class)
result(roll_no,m1,m2,m3)

q-1. Write Sql to create table for approprite constraints.

create table student


2 (
3 roll_no int primary key,
4 name varchar(10),
5 city varchar(12),
6 pin_code int
7 );

Data:
-------
ROLL_NO NAME CITY PIN_CODE CLASS
---------- ---------- ------------ ---------- ------
1 OM Bardoli 394350 FYBCA
2 SAI Bardoli 394350 FYBBA
3 RAM Sarbhon 394601 FYBCA
4 JAI Sarbhon 394601 SYBBA
5 SHREE Vyara 394701 SYBCA
6 Siya Surat 394301 SYBBA
7 Riya Vadodra 494301 SYCBA
8 Vikas Vadodra 494301 TYBBA
9 Vishal Vadodra 494301 TYBCA
10 Dipesh Rajkot 494301 TYBCA

create table result


2 (
3 roll_no int primary key,
4 m1 int,
5 m2 int,
6 m3 int,
7 foreign key(roll_no) refernces student(roll_no)
8 );

alter table result add total int;


update result set total=m1+m2+m3;

Data:
Page 1
sql query
--------

ROLL_NO M1 M2 M3 TOTAL
---------- ---------- ---------- ---------- ----------
1 45 60 57 162
2 97 95 89 281
3 60 62 75 197
4 60 42 55 157
5 35 25 15 75
6 15 15 15 45
7 45 56 50 151
8 80 82 75 237
9 62 64 70 196
10 44 64 50 158

Q-2: List name and total marks of all th students who are study in class FYBCA.
select s.name,r.total
from student s join result r
on s.roll_no=r.roll_no
where s.class='FYBCA';

Q-3. Display City Wise total total number of student.


select city,count(*) from student group by city;

Q-4. List The Name of students who scored more than 60% in mark2.
select s.name,r.m2
from student s
join result r
on s.roll_no=r.roll_no
where r.m2>r.m2*0.6;

Q-5. List out the name of student whose name start with 'v'.
select name from student where name like 'v%' or name like 'V%';

Page 2

You might also like