Databases SQL Reporting by Example Day 2: Advanced Selecting Students by Grade

Noah Fields
Noah Fields
13,985 Points

Math was Wrong

The difference between 6th and 7th grade was 17, not 27. As such, the growth curve is 24, followed by 17, for an average of 20.5.

Kareem Jeiroudi
Kareem Jeiroudi
14,982 Points

I didn't understand the calculation ?. How can you predict how many 6th graders will there be next year?

Marko Delgadillo
Marko Delgadillo
4,524 Points

I just saw this video and have NO IDEA how he got to the number of 6th graders from next year. Also, why was it in the lesson if it wasn't calculated with SQL? It threw me off.

Having said that, I am enjoying the videos and learning plenty :)

3 Answers

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

D'oh! Thanks for keeping me honest! It looks like we'll be making an update to this video in the near future :)

Fredric von Stange
Fredric von Stange
3,866 Points

Mistakes happen, nbd. I'm really enjoying the video series so far. Keep up the good work Ben!

Andrew Federico
Andrew Federico
7,483 Points

Just saw this. I'll remove my other post.

kevin hudson
PLUS
kevin hudson
Courses Plus Student 9,654 Points

So I must have missed something because the first thing I thought of was this:

SELECT COUNT(*), GRADE FROM STUDENTS GROUP BY GRADE;

But it was giving me a count of all students and so that led me to do UNIONS

SELECT COUNT(*) AS student_count, GRADE FROM STUDENTS WHERE GRADE = 8
UNION 
SELECT COUNT(*) AS student_count, GRADE FROM STUDENTS WHERE GRADE = 7
UNION
SELECT COUNT(*) AS student_count, GRADE FROM STUDENTS WHERE GRADE = 6;

Which did what I was looking for but I totally missed my mistake the first time and deleted it to do the UNIONS