180 likes | 462 Views
Good Afternoon. Select with relational operators. With the help of clauses we can filters our list. Syntax : Select <Col. Name……> from <table name> [where <condition>] Example : select * from student where mark=50 select * from student where mark>50
E N D
Select with relational operators With the help of clauses we can filters our list. Syntax : Select <Col. Name……> from <table name> [where <condition>] Example : select * from student where mark=50 select * from student where mark>50 select * from student where mark>=50 select * from student where mark<50 select * from student where mark<=50 select * from student where mark<>50
Select with logical operators Syntax : Select <Col. Name……> from <table name> [where <condition>] Example: Select * from student where mark>60 and mark<80 Select * from student where name=‘smith’ or name=john’ Select * from student where not address =‘cuttack’
Select with NULL Syntax : Select <Col. Name……> from <table name> [where <condition>] Example: Select * from student where name is null Select * from student where address is not null
Select with Between Syntax : Select <Col. Name……> from <table name> [where <condition>] Example: Select * from student where roll between 5 and 10 Select * from student where roll not between 5 and10
Select with in Syntax : Select <Col. Name……> from <table name> [where <condition>] Example: Select * from student where city in(‘ctc’,’bbsr’) Select * from student where city not in (‘ctc’, ‘bbsr’)
Select with like Syntax : Select <Col. Name……> from <table name> [where <condition>] Example: Select * from student where name like ‘_a’ Select * from student where name like ‘a%’ Select * from student where address like ‘a[d-j]%’ Select * from student where dept not like ’s%’
Select with distinct Syntax:Select [distinct | all] <col. name> from <table name> [where <condition>] Example: Select distinct address from student
Select with order by Syntax:Select <col. name> from <table name> [where <condition>][order by <col.list>] Example: Select * from student order by name
Select with aggregate functions Syntax:Select aggfun(<col. name>) from <table name> [where <condition>] Aggregate functions are: sum(), avg(), count(), max() & min() Example: Select sum(mark) from student Select avg(mark) from student Select max(mark) from student Select count(roll) from student where mark>40 Select min(mark)from student
Select name,max(mark) from student Will display the name of the students who have secured maximum mark
Select name from student Where mark = select max(mark) from student Sub Query