2 Replies - 1063 Views - Last Post: 09 November 2012 - 04:15 PM

#1 Siblyx   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-November 12

How to create views.

Posted 04 November 2012 - 04:24 PM

Hi all Can someone help me with my homework.
I know how to create a table , but view i realy dount know.

Calculate GPA by Item ID
     Shown in the result column PredmetID and the sum score, grouped by column in the table PredmetID StudentPredmet
     Calculate the average score for each student

My question is how to make views,and how to calculate the score for each student.


I placed the images in order so everyone understand my question. :tup:

Attached image(s)

  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: How to create views.

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: How to create views.

Posted 04 November 2012 - 05:47 PM

Hi.

I've moved your thread over to the MSSQL (Microsoft SQL Server) forum, as that is definitely what you are using. There is a big difference between MySQL and MSSQL; they are two entirely different SQL servers.


As to your question. I can show you the SQL syntax to create a view, but it seems like what you are doing is more about the UI of whatever MSSQL front-end you are using, about which I know practically nothing.

I'm also having kind of a hard time figuring out how to calculate those scores, as all your tables seem to be in a language I don't understand. (It's best to assume people around here will only understand English.)
Was This Post Helpful? 0
  • +
  • -

#3 Ionut   User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: How to create views.

Posted 09 November 2012 - 04:15 PM

It seems(hoppefully I understood correctly) "Ocena" is the column with grades.But I don't know what type of score you want to calculate, so I assume is arithmetic mean. Anyway, you have to use aggragate functions like sum and count: sum makes the some of the values on the column specified from the record set and count ..well counts the number of records depending on the condition, A starting point for you will be the next query
select StudentId, Sum(Ocena)/Count(Ocena) as Score
from StudentPredmet
Group By StudentId



A type of result set will be
StudentId | Score
1 | 8.66666

Make sure every column you add in select you have to add it in Group by section also.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1