Home » SQL & PL/SQL » SQL & PL/SQL » ranking
ranking [message #300006] Thu, 14 February 2008 00:24 Go to next message
avrillavinge
Messages: 98
Registered: July 2007
Member

Hi ,


I need syntax which reflets rank functionality.
bcoz....i have user inputs like start date , end date and top payments.
in the top payments if user enter 3 it has to show top three amounts
if user enter 10 it has to show top 10 payments......and it is given as default of 25.
if user didn't enter any value it has to show top 25 amounts..
so please give any idea..
thanks in advance....

Regards,
Avril
Re: ranking [message #300012 is a reply to message #300006] Thu, 14 February 2008 00:31 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Try searching for "Top N"
Re: ranking [message #300014 is a reply to message #300006] Thu, 14 February 2008 00:39 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
I am new to sql but am aware of top n


can u please help me with a similar code ..am confused as to @@ prompt feature is to be used ..

please help..Thnxx
Re: ranking [message #300015 is a reply to message #300014] Thu, 14 February 2008 00:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What is this @@ prompt?
We don't give full solution to newbie but we help them find it.
So search for "Top N" as Ross said.
You can also have a look at ROW_NUMBER, RANK and DENSE_RANK functions.

Regards
Michel
Re: ranking [message #300024 is a reply to message #300006] Thu, 14 February 2008 01:00 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
@@ is ampersand which will allow users to input their values.
i want to create a column called rank ..which wil display ranking according to profit ..

I have searched topicsa but couldnt get thru ..
Advise me more on which topics hsould i refer .Thnxx for the replies
Re: ranking [message #300032 is a reply to message #300024] Thu, 14 February 2008 01:11 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
@ is the at-sign
& is an ampersand
Re: ranking [message #300034 is a reply to message #300024] Thu, 14 February 2008 01:13 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
I have searched topicsa but couldnt get thru ..

Show us what you tried.

Regards
Michel
Re: ranking [message #300184 is a reply to message #300006] Thu, 14 February 2008 09:02 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
my misatke sorry . & ampersand is what i meant..
here is what i tried




select *
from yourtable
where datecol >= &startdate
and datecol <= &enddate
order by payments desc

Re: ranking [message #300202 is a reply to message #300184] Thu, 14 February 2008 10:35 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1/ &XXXX is a string, datecol is (I hope) a date, compare date with date not with string

2/ Did you search for "top n"? Did you read the link we posted?

Regards
Michel
Re: ranking [message #300370 is a reply to message #300006] Fri, 15 February 2008 04:06 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
thnxx ...

i got it.. million thanxxx for the help....

this forum..is gr88!!..

thankyou "Michel Cadot"

this is what i wanted
"select column1,column2 from (select column1,column2 from table order by 1 desc) where rownum<n+1"
Re: ranking [message #300372 is a reply to message #300370] Fri, 15 February 2008 04:11 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thanks for the feedback.

Next time, please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code and align the columns in result.
Use the "Preview Message" button to verify.
Always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: difference between @ and @@
Next Topic: Problem with %ROWTYPE
Goto Forum:
  


Current Time: Sun Dec 04 19:08:01 CST 2016

Total time taken to generate the page: 0.18496 seconds