0% found this document useful (0 votes)
16 views5 pages

Ass-1 Word-1

The document contains SQL queries and commands related to creating and managing teacher and subject tables. It includes table creation, data insertion, and various queries to retrieve specific information about teachers and their subjects. The queries address tasks such as finding teachers by subject count, salary, name patterns, and location.

Uploaded by

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

Ass-1 Word-1

The document contains SQL queries and commands related to creating and managing teacher and subject tables. It includes table creation, data insertion, and various queries to retrieve specific information about teachers and their subjects. The queries address tasks such as finding teachers by subject count, salary, name patterns, and location.

Uploaded by

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

Name:- Daksh Goswami

Roll No:-BCA22053
Class:-Division 1
ASSIGNMENT:-1
1. Consider the employee data. Give an expression in SQL for the
12 following query. Teacher (Tech_code, tname, join_date,
salary, city) Subject (Sub_Code, Sub_name, Tech_code).

Que 1:- Create tables and give proper constraints.

Ans:-

create table teacher (t_code int primary key,t_name


varchar2(20) not null,join_date date,salary int not null,city
varchar2(20) not null);
1. insert into teacher (t_code,t_name,join_date,salary,city)
values(101,'Kavita',to_date('01/01/2022','dd/mm/yyyy'),25000,'Surat');

2. insert into teacher (t_code,t_name,join_date,salary,city)


values(102,'Daksh',to_date('29/06/2022','dd/mm/yyyy'),45000,'Vapi');

3. insert into teacher (t_code,t_name,join_date,salary,city)


values(103,'Yashvi',to_date('30/06/2022','dd/mm/yyyy'),35000,'Valsad');

4. insert into teacher (t_code,t_name,join_date,salary,city)


values(104,'Micheal',to_date('01/01/2023','dd/mm/yyyy'),15000,'Navsari');

5. insert into teacher (t_code,t_name,join_date,salary,city)


values(105,'Amanda',to_date('21/01/2023','dd/mm/yyyy'),10000,'Dahod');

select * from teacher;

Ans:-
create table subject (sub_code int ,sub_name
varchar2(20) ,t_code int not null);
1. insert into subject (sub_code,sub_name,t_code) values(01,'ETIT',101);
2. insert into subject (sub_code,sub_name,t_code) values(02,'Computer
Graphics',102);
3. insert into subject (sub_code,sub_name,t_code) values(03,'RDBMS',103);
4. insert into subject (sub_code,sub_name,t_code) values(04,'Operating
System',103);
5. insert into subject (t_code) values(104);
6. insert into subject (sub_code,sub_name,t_code) values(06,'Programming
Skills',105);
select * from subject;
Que 2:- Find the name of teachers who are taking more than two
subjects.
Ans:-
select teacher.t_name,
teacher.t_code,subject.sub_name,subject.sub_code from teacher
inner join subject on teacher.t_code=subject.t_code where
t_name='Yashvi' ;

Que 3:- Display the name of teacher who get salary more than
35000 and teach "Computer graphics" subject.
Ans:-

select
teacher.t_name,teacher.t_code,teacher.salary,subject.sub_name
From teacher inner join subject on teacher.t_code=subject.t_code
where sub_name='Computer Graphics' and salary>35000;
Que 4:- Display the name of teacher whose name start with 'K'
and end with 'A'.
Ans:-
select * from teacher where t_name like 'K%a';

Que 5:- Count the teacher who is not taking any subject.
Ans:-
SELECT COUNT(t_code),t_name FROM teacher WHERE t_code =
105 GROUP BY t_name;

6 Display the name of teacher who is situated in 'Valsad' and


taking 'RDBMS' and 'Operating system' subjects.

Ans:-

select teacher.t_name,
teacher.t_code,subject.sub_name,teacher.city from teacher inner
join subject on teacher.t_code=subject.t_code where city='Valsad'
and sub_name in('RDBMS','Operating System');

You might also like