Student table and employee table sql aggregation min max count avg sum and like operator

 Create student table**

create table student(studentid int, sname varchar2(10));

insert into student values(1,'akash');

insert into student values(2,'mitali');

insert into student values(3,'sanjay');

insert into student values(5,'sonali');

insert into student values(4,'anuj');

Query 1*

select*from student

where sname

like 'a%';


Query2*
select*from student
where sname
like '%i';

Query 3*

select*from student

where sname

like '%an%';

Query4*

select*from student

where sname

like '_o%';

Query 5*

select*from student

where sname

like '__n%';

Query6*
select*from student
where sname
like 'a__%';

Query 7*
select*from student
where sname
like 'm%i';
Create table employee**

create table employee(eid varchar2(5),ename varchar2(10),age int,city varchar2(15),salary int);
insert into employee values('e001','raj',23,'ahmedabad',2000);
insert into employee values('e002','mohit',23,'delhi',3000);
insert into employee values('e003','daniel',21,'mumbai',4000);
insert into employee values('e004','sania',24,'indore',5000);
insert into employee values('e005','tayal',25,'udaipur',4000);

Query1*

select min(salary) 

from employee;



Query 2*

select max(salary) 

from employee;



Query 3*

select avg(salary) 

from employee;



Query4*

select sum(salary) 

from employee;



Query 5*

select count(salary) 

from employee;

Create table customer**
create table customer(cid int,fname varchar2(10),lname varchar2(10));
insert into customer values(1,'jackson','joe');
insert into customer values(2,'smith','jane');
insert into customer values(3,'raynolds','allen');
insert into customer values(4,'anderson','paige');
insert into customer values(5,'johnson','deck');
Query1*
select*from customer
where lname
like 'j%';
Query 2*
select*from customer
where fname
like '_a%';
Query3*
select*from customer
where lname
like 'd%k';

Query4*
select*from customer
where fname
like '%o%';








Comments

Popular Posts