B
B
bender30002014-12-10 18:06:43
MySQL
bender3000, 2014-12-10 18:06:43

How to write a query in SQL database?

Knowledgeable people, please stop.
I volunteered to make the teachers' work easier and I can't do without your help!
The school has a database of marks, and it is necessary to generate a report for one subject . The data is not explicit and has to be collected piece by piece. The result should look like this: The Class
19595de2a6b74f7cbf55fc3717c5b979.png
column is static and does not change values . The Number column is the number of students. They helped me write the following query:

SELECT concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',course.id,'">',course.fullname,'</a>') AS Course,
COUNT(course.id) AS Students
FROM prefix_role_assignments AS asg
JOIN prefix_context AS context ON asg.contextid = context.id AND context.contextlevel = 50
JOIN prefix_user AS USER ON USER.id = asg.userid
JOIN prefix_course AS course ON context.instanceid = course.id
WHERE asg.roleid = 5 
AND course.fullname LIKE '%Қазақ тілі%'

but does not display the sum of students in all 6th or 7th grades;
The rest of the blocks are the same. Criterion A has mrs_grade_items.idnumber = 'a1' in the table, and the assessment lies in the prefix_grade_grades.finalgrade table, which is linked by the prefix_grade_grades.itemid field.
Here you need the sum of all values ​​with the condition IF prefix_grade_grades.finalgrade <=2 then enter in the "1-2" field

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question