Divide data from different tables in sql

0

I'm doing an sql query to get averages of accesses for which I first make a query to extract all the accesses of a table and divide them for another field of a different table.

The first table is called TrackEvent and from it I extract a column which the

I have divided for a number to get an average with the following query:

select count(event)/74 from ABC.TrackEvent where course_display_name = "course-v1-AGROSYS-Ed2-2017-FEB" and session !="";

The other table that I have is called students and has only two columns, the first is the name of the course and the next the number of students. that is to say: Table students

course: course-v1-AGROSYS-Ed2-2017-FEB

student_numbers: 74

How can I do to replace the number 74 of the query before shown by the value of the column number students of the table students.

thanks

    
asked by Gerardo Gutiérrez 25.09.2017 в 23:48
source

1 answer

1
SELECT COUNT(event)/(SELECT numero_estudiantes FROM Tabla_estudiantes WHERE course_display_name = "course-v1-AGROSYS-Ed2-2017-FEB" ) from ABC.TrackEvent where course_display_name = "course-v1-AGROSYS-Ed2-2017-FEB" and session !=""; 

I think that with a subquery it goes

    
answered by 26.09.2017 в 00:06