sql - count and repetive structure -


we have 490 students have capacity of 20 students per classroom ie have 490/20 = 24.5 ie 25 sections first want arrange students in alphabetical order secondly want make table containing id_classroom , id_student attributes problem in id_classroom , how populate how can automatically give students 1 20 === id_classroom = 1 students 21 40 === id_classroom = 2 , on

thank in advance

in sql resquest, function floor friend. reduce number largest integer less or equal expression.

let's have student id 46. operation this:

46-1= 45     //index starts @ 1 instead of 0. 45/20=2.25    floor(2.25)=2    2+1=3  

so sql have such in it:

id_classroom=floor((id_student-1)/20)+1 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -