Professional Web Applications Themes

Select a student with the highest GPA - Microsoft SQL / MS SQL Server

Hi friends, I have a Students table that contains student information (name, DOB, GPA, etc.). I want to use a single SELECT statement to select the name, DOB, GPA of the student who has the highest GPA. What should the statement look like? Thanks!...

  1. #1

    Default Select a student with the highest GPA

    Hi friends,

    I have a Students table that contains student information
    (name, DOB, GPA, etc.). I want to use a single SELECT
    statement to select the name, DOB, GPA of the student who
    has the highest GPA. What should the statement look like?

    Thanks!
    Your Guest

  2. #2

    Default Re: Select a student with the highest GPA

    select top 1 name, DOB, GPA
    from <table>
    order by gpa desc

    --
    -Vishal

    "Your Friend" <com> wrote in message
    news:0b2301c356ca$e89b24d0$gbl... 


    Vishal Guest

  3. #3

    Default Re: Select a student with the highest GPA

    Hi Vishal,

    Thanks a lot for the quick reply! I guess my requirements
    are actually a little more complicated: the Students table
    also has a column 'ClassID'. I want to get the name, DOB,
    GPA for all students who earned the highest GPA in his/her
    class.

    Thanks a lot!
    Your Friend.
     [/ref]
    information [/ref]
    who [/ref]
    like? 
    >
    >
    >.
    >[/ref]
    Your Guest

  4. #4

    Default Re: Select a student with the highest GPA

    select top 1 WITH TIES name, DOB, GPA
    from <table>
    order by gpa desc

    I'd hate for some kid to get left if two or more students have the same
    highest GPA.

    David

    "Vishal Parkar" <com> wrote in message
    news:Oyk9$phx.gbl... 
    >
    >[/ref]


    David Guest

  5. #5

    Default Re: Select a student with the highest GPA

    Select name,dob,gpa from table where gpa in (select max(gpa) from table)

    Sh


    "Your Friend" <com> wrote in message
    news:507701c356ce$33f51fa0$gbl... [/ref]
    > information [/ref]
    > who [/ref]
    > like? 
    > >
    > >
    > >.
    > >[/ref][/ref]


    Shamim Guest

  6. #6

    Default Re: Select a student with the highest GPA

    Thanks, Tom!
    That's exactly what I was looking for!

     
    ----- 
    news:507701c356ce$33f51fa0$gbl... 
    table 
    his/her [/ref]
    >information [/ref]
    >who [/ref]
    >like? 
    >>
    >>
    >>.
    >>[/ref]
    >[/ref]
    Your Guest

  7. #7

    Default Re: Select a student with the highest GPA

    Thanks, Wayne!
    That is a good example which helps to address my problem.

     
    and type substitute 
    Charlotte, NC 
    (PASS) and it community [/ref]
    information [/ref]
    who [/ref]
    like? 
    >
    >
    >.
    >[/ref]
    Your Guest

Similar Threads

  1. Highest Distinct Value
    By mslima in forum Coldfusion Database Access
    Replies: 4
    Last Post: April 19th, 01:42 PM
  2. what's the highest version of FH10?
    By phorest in forum Macromedia Freehand
    Replies: 0
    Last Post: July 26th, 10:38 PM
  3. Invest 6$ 1 time get HIGHEST Output!!!
    By malik in forum ASP.NET Building Controls
    Replies: 0
    Last Post: February 19th, 08:32 PM
  4. How to load a movie in the next highest level??
    By printmasterstudio webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: January 21st, 06:40 AM
  5. How get highest and lowest dates for a report
    By Dale Glaser in forum FileMaker
    Replies: 2
    Last Post: August 7th, 08:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139