Database SQL
Database SQL
What is SQL?
Electrical Girls ?
2) sex = "F"
What is "age“?
Functions:
1 d.p. : ROUND(__ , 0)
eg. 3 List the names and ages of Electrical girls.
name age
Result Bindhu 21.0
: :
Comparison
expr IN ( value1, value2, value3)
expr BETWEEN value1 AND value2
expr LIKE "%_"
eg. 4 List the students who were born on Wednesday
or Saturdays.
name dept
Result Ram Electrical
: :
Grouping
SELECT ...... FROM ...... WHERE condition ;
GROUP BY groupexpr [HAVING requirement]
Group functions:
COUNT( ), SUM( ), AVG( ), MAX( ), MIN( )
dept cnt
Result Mechanical 3
Electrical 2
Group By dept
dept
Electrical
Mechanical
Mechanical
Mechanical Mechanical
Mechanical
AVG( )
Mechanical
Student
eg. 7 List the average entrance test score of each dept.
dept avg_etest
Result Electrical 90.00
Mechanical 81.66
Grouping - Having
eg. 8 List the average Entrance test score of the boys in
each class. The list should not contain dept with
less than 3 boys.
Same id 9801
9801
Join
Student Music
9801
Product
Thank You