Mysql Update on Average Students

Asked

Viewed 71 times

-1

Hi, good, I have a comic book with several students inserted, and in the exercise I need to average them and insert them in a new column. But when I do a test select before I update my command it puts together all the grades of all the students and takes an average of that. How do I get the average student per student ? my code : select (avg(P1)+avg(P2)) from notes; I’m not even sure how to research my problem.

inserir a descrição da imagem aqui

  • 1

    Update notes set media = (((P1+P2)/2) , maybe a round is missing depending on the column type. Another solution may be to create a virtual column

  • So you put an image of your code and/or error message. Although it seems like a good idea, it’s not! Understand the reasons here

1 answer

0


Do it this way, it’ll work inserir a descrição da imagem aqui

  • If you want to make it more organized, just do asism SELECT * ((n1+N2)/2) AS 'Media' FROM NOTES

  • 1

    Gustavo, prefer text code to image code. Explanation of why here

  • So I get kkk , but I wanted to use avg, is it not possible ? but thank you anyway :3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.