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

ASSIGNMENT NO 5

TITLE: Execute select queries using order by, group by, aggregate functions, having clause,
and set operators. Use SQL single row function for date, time, string etc..

Name: Ranjeet R Raigawali Roll no : 75 Batch:4th

Grno:182012 Branch: IT

SELECT QUERIES :

1) ORDER BY :

select * from student order by stud_id;

select * from student order by f_name;

select h_name from hostel order by h_id desc;

select * from stud_mobile order by s_mobno;

select salary from employee1 where h_id =2 order by salary ;

2) GROUP BY :

select COUNT(s_mobno) from stud_mobile group by s_mobno;

select room_no from hostel_stud group by room_no;

select h_name from hostel group by h_name order by h_name;

select h_name from hostel group by h_name ;

3) Aggregate Functions :

select count (stud_id) from student;

select count(s_mobno) from stud_mobile group by s_mobno;

select avg(salary) from employee1 ;

select avg(salary) from employee1 where h_id=1 ;

select sum(salary) from employee1;


select max(salary) from employee1 where h_id=1;

select sum(salary) from employee1 group by (h_id);

select max(salary) from employee1 group by (h_id);

select avg(salary) from employee1 group by (h_id);

4) HAVING CLAUSE :

select max(salary),emp_name from employee1

group by(emp_name)

having max(salary)>10000;

select max(salary),emp_name from employee1

group by (emp_name)

having max(salary)< 50000;

5) SET OPERATORS :
a) UNION :

select stud_id,f_name from student

union

select h_id,h_name from hostel;

b) UNION ALL :

select stud_id,f_name from student

union all

select h_id,h_name from hostel;


c) INTERSECT :

select stud_id,f_name from student

intersect

select h_id,h_name from hostel;

d) MINUS :

select stud_id,f_name from student

minus

select h_id,h_name from hostel;

6) SINGLE ROW FUNCTION :


i) DATE :

select sysdate from dual;

select sysdate,current_timestamp from dual;

ii) TIME :

select CURRENT_TIMESTAMP from dual;

iii) STRING:
select ascii('A') from dual;
select upper('ranjeet raigawali') from dual;
select lower('RANJEET RAIGAWALI') from dual;
select initcap('ranjeet raigawali')from dual;
select chr(65) from dual;
select concat('ranjeet','raigawali')from dual;
select length('RANJEET RAIGAWALI') from dual;

You might also like