Newbie Help working out a SQL Problem..

  • (I need to be pointed in the right direction on this)

    a.Find the Most Points scored per game by Position

    b.Find the Number of Rebounds per game by Coach

    NOW, I know these questions are very similiar..the very process I will use to solve one will also solve the other...The part where I get confused is the "per game" part... What is the best way to begin to tackle this...

  • smiF (4/14/2016)


    (I need to be pointed in the right direction on this)

    a.Find the Most Points scored per game by Position

    b.Find the Number of Rebounds per game by Coach

    NOW, I know these questions are very similiar..the very process I will use to solve one will also solve the other...The part where I get confused is the "per game" part... What is the best way to begin to tackle this...

    Is this homework?

    What have you tried?

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • smiF (4/14/2016)


    (I need to be pointed in the right direction on this)

    a.Find the Most Points scored per game by Position

    b.Find the Number of Rebounds per game by Coach

    NOW, I know these questions are very similiar..the very process I will use to solve one will also solve the other...The part where I get confused is the "per game" part... What is the best way to begin to tackle this...

    not sure what you want ..."per game" suggests you have data "per game". But thats not what you have shown...you have given "games-played" (ie a summary).

    perhaps you can update us with your expected results

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • how to present a question with easy to use script for all .

    https://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/

    voila:

    CREATE TABLE Bball_Stats(

    PlayerId INTEGER NOT NULL PRIMARY KEY

    ,PlayerName VARCHAR(7) NOT NULL

    ,PlayerNum INTEGER NOT NULL

    ,PlayerPosition VARCHAR(7) NOT NULL

    ,Assist INTEGER NOT NULL

    ,Rebounds INTEGER NOT NULL

    ,Games_Played INTEGER NOT NULL

    ,Points INTEGER NOT NULL

    ,PlayersCoach VARCHAR(8) NOT NULL

    );

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (1,'ali',20,'guard',125,80,10,60,'thompson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (2,'james',22,'forward',65,100,10,65,'garret');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (3,'ralph',24,'center',30,120,9,70,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (4,'terry',30,'guard',145,90,9,75,'garret');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (5,'dirk',32,'forward',70,110,10,80,'thompson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (6,'alex',34,'center',35,130,10,90,'garret');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (7,'nina',40,'guard',155,100,9,100,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (8,'krystal',42,'forward',75,100,9,95,'thompson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (9,'bud',44,'center',40,125,10,90,'thompson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (10,'tiger',50,'guard',160,90,10,85,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (11,'troy',52,'forward',80,125,10,80,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (12,'anand',54,'center',50,145,10,110,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (13,'kishan',60,'guard',120,150,9,115,'samson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (14,'spock',62,'forward',85,105,8,120,'thompson');

    INSERT INTO Bball_Stats(PlayerId,PlayerName,PlayerNum,PlayerPosition,Assist,Rebounds,Games_Played,Points,PlayersCoach) VALUES (15,'cow',64,'center',55,175,10,135,'samson');

    SELECT PlayerId,

    PlayerName,

    PlayerNum,

    PlayerPosition,

    Assist,

    Rebounds,

    Games_Played,

    Points,

    PlayersCoach

    FROM Bball_Stats;

    SELECT PlayerPosition,

    MAX(Points) AS maxpoints

    FROM Bball_Stats

    GROUP BY PlayerPosition;

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Yes...it is home work... My real question is actually can the following question be answered with the attached data. I feel that the question has a flaw to it....what have I tried several things are that all begin and end with accumulating an average for the scores....which could derive me ....the expected answer...but I want to know....am I wrong to think...that in a real life application.. This question would not be supplying enough data to determine the answer... I hats where I'm at...I have answers to the posted question but this one remains...a ????

  • To get the points per game, you need to divide the points by the games played. Then you need to get the greatest value using an aggregate function and grouping them by position.

    Be careful though, there's something called integer division that might give you problems. You need to convert the values into a data type with a decimal point.

    Try this as an example:

    SELECT 99/10 AS IntegerDivision,

    99/10.0 AS NormalDivision;

    I'm not giving you the answer, but I hope this would guide you.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply