Computer Science, asked by ssnithyatony, 8 months ago

Q2. Write SQL query for the following tables:
T1(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 rollinois 1
3. Delete student details whose age is 18.
4. Retrieve branch information in descending onder
5. Listaill names of all students who have age between 20 and 2​5

Answers

Answered by muruganpalaniswamy
3

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

Answered by kaushanimisra97
0

Answer:

The GROUP BY clause must be used in conjunction with an aggregate function like AVG to determine the aggregate value of one column in relation to another column.

Explanation:

How to Find Average Marks of Each Student in SQL?

In SQL, there are occasions when it's necessary to calculate the average value of a column based on the value of another column in the table, such as when calculating the average grades each student has earned across all of their disciplines.

The GROUP BY clause and an AGGREGATE function, such as AVG, are used in this situation.

The article that follows illustrates this.

For the sake of this article, our database will be the Microsoft SQL Server.

Build a database as the first step. Create a database named GeeksForGeeks using the command listed below.

Query:

GeeksForGeeks DATABASE CREATION.

To Learn more About AVG Refer To:

https://brainly.in/question/49813929

https://brainly.com/question/20118982

#SPJ2

Attachments:
Similar questions