Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: query help

  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    18
    Thanks
    6
    Thanked 0 Times in 0 Posts

    query help

    iam doing student record project.40 students studying 5 subjects , i want to write sql query to display records of students who scored top 4 marks in each subject.so totaly 20 records to be displayed

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What you have done so far?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,196
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    And, more importantly, what is your DB design?

    If you only have one table, not at least two tables and probably three or more, then it's a bad design that will only be made worse by trying to do this query.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New Coder
    Join Date
    Sep 2012
    Location
    USA
    Posts
    13
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi ! i don't give you ans because you didn't explain the fields of your Tables. Can you explain it Clearly?

  • Users who have thanked JefferyJamison for this post:

    arun.xavier50 (03-11-2013)

  • #5
    New Coder
    Join Date
    May 2011
    Posts
    18
    Thanks
    6
    Thanked 0 Times in 0 Posts

    data base design

    my database design as follows

    student_name subject1_mark subject2_mark subject3_mark subject4_mark subject5_mark

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,196
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    Bad design. Makes it tough to create a good query.

    Your only real choice is 5 separate queries, though you could use a UNION to make it *look* like one query.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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