Q2. Write SQL query for the following tables:
TI(rollno, stuname, age, city, branchcode)
T2(branchcode, branchname)
1. Find an average age of all students,
2. Change age of student to 20 to 22 whose rollno is 1
3. Delete student details whose age is 18.
4. Retrieve branch information in descending order.
5. List all names of all students who have age between 20 and 25.
Answers
Answered by
0
Answer:
1. select AVG(age) from T1
2. update T1 set age = 22 where rollno=1
3. delete from T1 where age = 18
4. select branchname from T2 order by desc
5. select stuname from T1 where age between 20 and 25
Explanation:
1. Query type: Select column with apply a function,
AVG() function is used to calculate the average of the age.
2. Query type : Update the existing record with where condition
3. Query type: Delete the record with where condition
4. Query type: select with order by
5. Query type: Select with where condition
Similar questions