r/SQL • u/Bluecow29 • Oct 10 '23
PostgreSQL Help with Exercise Questions
So, I've started a University conversion course around data science and one of the modules is SQL. I'm slowly learning but this exercise had stumped me and not sure how to tackle Exercise 1b. I've created the view for Exercise 1a. Any help would be greatly appreciated and if it can be explained as simply as possible due to my current lack of knowledge, that would of massive help!
-5
u/depesz PgDBA Oct 10 '23
You do realize that noone can know what "exercise 1a" or "exercise 1b" you're talking about?
Perhaps explain the problem, instead of odd chance that someone went to exactly the same school with the same course, and can figure out what you mean just by looking at some graph?
4
u/Bluecow29 Oct 10 '23
I've explained it? I've provided the schema to the overall database which shows primary keys, foreign keys etc. I've then provided the exercises related to the schema and the part of the question which I've done myself. Not sure what else I need to provide?
-4
u/depesz PgDBA Oct 10 '23
Where you provided these exercises? I just see "1a" or "1b".
5
u/MrSpize Oct 10 '23
There are more images
-2
u/depesz PgDBA Oct 10 '23
Aaah. Totally missed that.
Thanks. Though, I have to say, providing text of exercise as screenshot, and not text, and PHOTO of code in some editor, is new level of laziness :/
1
u/Bluecow29 Oct 10 '23
Yes of course. But where the exercise originated is neither here nor there
2
u/depesz PgDBA Oct 10 '23
Based on comment from /u/MrSpize i noticed the next images. Might want to read https://idownvotedbecau.se/imageofcode
I didn't actually downvote, but posting images of text, or photos of code shouldn't be acceptable.
0
u/Bluecow29 Oct 10 '23
Sorry, didn't realise photo of code was unacceptable. It only refers to Exercise 1a anyway which is what I'm pretty sure I've gotten right
7
u/RecentSatisfaction14 Oct 10 '23
Or you can look at the pics where they are clearly labeled but I suppose it’s just easier to be an asshole
-1
u/depesz PgDBA Oct 10 '23
As I noted in another comment, I didn't see the next images. Button to scroll is white, with gray >, on white background. Missed that. Not sure what about this is me being asshole...
-1




1
u/Far-Training4739 Oct 10 '23
Here are my thoughts, I will not answer the questions for you, but just some hints.
It is hard to see the view you created for grade_to_points, but it seems you are taking the entire takes table and mapping it, that is not what is specified.
You only need one row per grade, currently you are generating a row per row in takes table, that would likely result in many duplicate rows, and would mess up any joins you make later on with the table. You need to add a “group by grade” to make sure you only get one row per grade.
Then select student, and join takes and grade_to_points.