to write code

5 pts.
Tags:
Oracle SQL
SQL
i have created a table "stu" in which the following record exists. stu_id,stu_name,stu_course,stu_marks the stu_marks column output is as follows 822 758 789 658 822 879 598 825 589 785 795 795 658 789 988 what i want is to write query or code (function,procedure or anything) that when i execute it prompts the user to enter whether he want to have top 10 students marks(according to marks),top 5,top 3,2,1 inshort from top1-top15 and when he enters top1 so the highest marks of the student should be displayed,similary if user enters top 10 so the 10 studnets marks will be displayed in descending order i would be grateful to you if u kindly do it

Answer Wiki

Thanks. We'll let you know when a new response is added.

Any chance of changing the schema? Having all marks of a student in a space delimited fields represtents issues as I am sure you have found out. Add another table called stu_marks with 2 fields
the stu_id, and the stu_marks. Each students marks gets its own row. This makes it much easier to do a top anything query , and allow for easy ordering (ascending or descending). What version of Oracle are you running? There are many ways of doing it oracle 11 has some new features for pivot table which would assist with this. You can use a split function see asktom.oracle.com for explanation on that, and use a temporary table to store the data in it, to get the top XX with sorting.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Definitely it would be much easier to accomplish this (and many other things) with a different schema... Was there some special reason to store the marks in this way ?
    69,510 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following