| |

VerySource

 Forgot password?
 Register
Search
View: 1200|Reply: 3

Can't write select statement in avg aggregate function?

[Copy link]

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2021-3-10 13:00:02
| Show all posts |Read mode
Like the title, does it have to be listed?
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2021-3-10 13:15:01
| Show all posts
select avg(t.id) from (select top 10 id from sysobjects order by id)t
Reply

Use magic Report

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2021-3-10 14:30:01
| Show all posts
What if I use avg in the update statement?

Change the grade of student No. 105 for elective course No. 203 to the average grade of the changed course.
update elective set score=avg(select score from elective where course number=203) where student number=105

How to change this to be correct?
It shouldn't be necessary to post the structure and data of the entire database.
Reply

Use magic Report

0

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2021-3-10 15:00:01
| Show all posts
UPDATE elective
SET score=(SELECT AVG(score) FROM elective WHERE course number=203)
WHERE student ID=105
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list