Ranking function in PHP/MySQL

Ranking function in PHP/MySQL

am 06.10.2007 20:16:01 von COLLEEN

Hello!

I've only been dabbling in PHP and MySQL for a few months.

I'm trying to find out if there's a query/function similar to the RANK
function in Excel.

What I want to be able to do is take a list of dates from a particular
table field, and be able to rank each record in the order within which
in falls in those range of dates, because records are not always
entered in chronological order.

Here's a partial sampling of my table, showing the relevant fields for
this query.

casualtyID deathdate
1 2003-12-01
2 2007-06-20
3 2002-08-30
4 2007-01-01
5 2005-04-11

So, from this "ranking" query (that would generate the result $rank),
I want to be able to say:
echo "$casualtyID is the number $rank casualty to die in the current
wars in Iraq and Afghanistan\n";


Thank you!

Colleen Robledo
http://www.colleenrobledo.info

Re: Ranking function in PHP/MySQL

am 06.10.2007 21:43:35 von Shelly

"Colleen" wrote in message
news:1191694561.785242.199670@o80g2000hse.googlegroups.com.. .
> Hello!
>
> I've only been dabbling in PHP and MySQL for a few months.
>
> I'm trying to find out if there's a query/function similar to the RANK
> function in Excel.
>
> What I want to be able to do is take a list of dates from a particular
> table field, and be able to rank each record in the order within which
> in falls in those range of dates, because records are not always
> entered in chronological order.
>
> Here's a partial sampling of my table, showing the relevant fields for
> this query.
>
> casualtyID deathdate
> 1 2003-12-01
> 2 2007-06-20
> 3 2002-08-30
> 4 2007-01-01
> 5 2005-04-11
>
> So, from this "ranking" query (that would generate the result $rank),
> I want to be able to say:
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
>
> Thank you!
>
> Colleen Robledo
> http://www.colleenrobledo.info
>

select casualtyID, deathdate from the_table order by deathdate

Then the results will be in deathdate order and as you loop through the
results you know what the index/rank of each individual casualtyID is.

Shelly

Re: Ranking function in PHP/MySQL

am 06.10.2007 23:15:01 von Macca

>select casualtyID, deathdate from the_table order by deathdate


Just to eloborate on that you can use the keywords ASC and DESC for
ascending order and descending order respectively, such as

"SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate ASC"

Re: Ranking function in PHP/MySQL

am 06.10.2007 23:29:11 von Jerry Stuckle

Colleen wrote:
> Hello!
>
> I've only been dabbling in PHP and MySQL for a few months.
>
> I'm trying to find out if there's a query/function similar to the RANK
> function in Excel.
>
> What I want to be able to do is take a list of dates from a particular
> table field, and be able to rank each record in the order within which
> in falls in those range of dates, because records are not always
> entered in chronological order.
>
> Here's a partial sampling of my table, showing the relevant fields for
> this query.
>
> casualtyID deathdate
> 1 2003-12-01
> 2 2007-06-20
> 3 2002-08-30
> 4 2007-01-01
> 5 2005-04-11
>
> So, from this "ranking" query (that would generate the result $rank),
> I want to be able to say:
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
>
> Thank you!
>
> Colleen Robledo
> http://www.colleenrobledo.info
>

Next time, please post your SQL questions to a MySQL newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 00:19:26 von sheldonlg

"macca" wrote in message
news:1191705301.404195.116550@22g2000hsm.googlegroups.com...
> >select casualtyID, deathdate from the_table order by deathdate
>
>
> Just to eloborate on that you can use the keywords ASC and DESC for
> ascending order and descending order respectively, such as
>
> "SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate ASC"

If you don't specify anything, ASC is taken by default.

Re: Ranking function in PHP/MySQL

am 07.10.2007 00:20:12 von sheldonlg

"Jerry Stuckle" wrote in message
news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
> Colleen wrote:
>> Hello!
>>
>> I've only been dabbling in PHP and MySQL for a few months.
>>
>> I'm trying to find out if there's a query/function similar to the RANK
>> function in Excel.
>>
>> What I want to be able to do is take a list of dates from a particular
>> table field, and be able to rank each record in the order within which
>> in falls in those range of dates, because records are not always
>> entered in chronological order.
>>
>> Here's a partial sampling of my table, showing the relevant fields for
>> this query.
>>
>> casualtyID deathdate
>> 1 2003-12-01
>> 2 2007-06-20
>> 3 2002-08-30
>> 4 2007-01-01
>> 5 2005-04-11
>>
>> So, from this "ranking" query (that would generate the result $rank),
>> I want to be able to say:
>> echo "$casualtyID is the number $rank casualty to die in the current
>> wars in Iraq and Afghanistan\n";
>>
>>
>> Thank you!
>>
>> Colleen Robledo
>> http://www.colleenrobledo.info
>>
>
> Next time, please post your SQL questions to a MySQL newsgroup.

This was actually both an SQL and a php question.

Re: Ranking function in PHP/MySQL

am 07.10.2007 03:02:55 von luiheidsgoeroe

On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
wrote:
> "Jerry Stuckle" wrote in message
> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>> Colleen wrote:
>>> I'm trying to find out if there's a query/function similar to the RANK
>>> function in Excel.
>>> What I want to be able to do is take a list of dates from a particular
>>> table field, and be able to rank each record in the order within which
>>> in falls in those range of dates, because records are not always
>>> entered in chronological order.
>>> So, from this "ranking" query (that would generate the result $rank),
>>> I want to be able to say:
>>> echo "$casualtyID is the number $rank casualty to die in the current
>>
>> Next time, please post your SQL questions to a MySQL newsgroup.
>
> This was actually both an SQL and a php question.
>

Euhm, how is PHP involved again?
--
Rik Wasmus

Re: Ranking function in PHP/MySQL

am 07.10.2007 03:06:38 von Shelly

"Rik Wasmus" wrote in message
news:op.tzsyi5zq5bnjuv@metallium.lan...
> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
> wrote:
>> "Jerry Stuckle" wrote in message
>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>> Colleen wrote:
>>>> I'm trying to find out if there's a query/function similar to the RANK
>>>> function in Excel.
>>>> What I want to be able to do is take a list of dates from a particular
>>>> table field, and be able to rank each record in the order within which
>>>> in falls in those range of dates, because records are not always
>>>> entered in chronological order.
>>>> So, from this "ranking" query (that would generate the result $rank),
>>>> I want to be able to say:
>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>
>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>
>> This was actually both an SQL and a php question.
>>
>
> Euhm, how is PHP involved again?
> --
> Rik Wasmus

After getting the results, the looping through each record in order to
output the results.

Re: Ranking function in PHP/MySQL

am 07.10.2007 04:34:02 von Jerry Stuckle

Shelly wrote:
> "Rik Wasmus" wrote in message
> news:op.tzsyi5zq5bnjuv@metallium.lan...
>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>> wrote:
>>> "Jerry Stuckle" wrote in message
>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>> Colleen wrote:
>>>>> I'm trying to find out if there's a query/function similar to the RANK
>>>>> function in Excel.
>>>>> What I want to be able to do is take a list of dates from a particular
>>>>> table field, and be able to rank each record in the order within which
>>>>> in falls in those range of dates, because records are not always
>>>>> entered in chronological order.
>>>>> So, from this "ranking" query (that would generate the result $rank),
>>>>> I want to be able to say:
>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>> This was actually both an SQL and a php question.
>>>
>> Euhm, how is PHP involved again?
>> --
>> Rik Wasmus
>
> After getting the results, the looping through each record in order to
> output the results.
>
>

Bullshit. You can't rationalize your way out of this one, Shelly.

The question was a SQL question, and the answer was a SQL answer.

Or, please tell me how "ORDER BY by deathdate" has ANYTHING to do with PHP.

Or, where you had ANY PHP code in your answer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 05:41:32 von Shelly

"Jerry Stuckle" wrote in message
news:du2dnUdgBowD2JXanZ2dnUVZ_oLinZ2d@comcast.com...
> Shelly wrote:
>> "Rik Wasmus" wrote in message
>> news:op.tzsyi5zq5bnjuv@metallium.lan...
>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>> wrote:
>>>> "Jerry Stuckle" wrote in message
>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>> Colleen wrote:
>>>>>> I'm trying to find out if there's a query/function similar to the
>>>>>> RANK
>>>>>> function in Excel.
>>>>>> What I want to be able to do is take a list of dates from a
>>>>>> particular
>>>>>> table field, and be able to rank each record in the order within
>>>>>> which
>>>>>> in falls in those range of dates, because records are not always
>>>>>> entered in chronological order.
>>>>>> So, from this "ranking" query (that would generate the result $rank),
>>>>>> I want to be able to say:
>>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>> This was actually both an SQL and a php question.
>>>>
>>> Euhm, how is PHP involved again?
>>> --
>>> Rik Wasmus
>>
>> After getting the results, the looping through each record in order to
>> output the results.
>
> Bullshit. You can't rationalize your way out of this one, Shelly.

Temper, temper. Easy now. No need to let your blood boil over what amounts
to trivialities.

>
> The question was a SQL question, and the answer was a SQL answer.
>
> Or, please tell me how "ORDER BY by deathdate" has ANYTHING to do with
> PHP.

Nothing. That line is pure SQL.

> Or, where you had ANY PHP code in your answer.

Look above. You get a resource from executing the query. If you don't
agree that the reading the fields from each row of the result resource
obtained from the query, or the continuous looping through that set till
exhausted, or the output of each of these rows as html, is php, then we will
simply have to agree to disagree.

Shelly

Re: Ranking function in PHP/MySQL

am 07.10.2007 06:24:48 von Jerry Stuckle

Shelly wrote:
> "Jerry Stuckle" wrote in message
> news:du2dnUdgBowD2JXanZ2dnUVZ_oLinZ2d@comcast.com...
>> Shelly wrote:
>>> "Rik Wasmus" wrote in message
>>> news:op.tzsyi5zq5bnjuv@metallium.lan...
>>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>>> wrote:
>>>>> "Jerry Stuckle" wrote in message
>>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>>> Colleen wrote:
>>>>>>> I'm trying to find out if there's a query/function similar to the
>>>>>>> RANK
>>>>>>> function in Excel.
>>>>>>> What I want to be able to do is take a list of dates from a
>>>>>>> particular
>>>>>>> table field, and be able to rank each record in the order within
>>>>>>> which
>>>>>>> in falls in those range of dates, because records are not always
>>>>>>> entered in chronological order.
>>>>>>> So, from this "ranking" query (that would generate the result $rank),
>>>>>>> I want to be able to say:
>>>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>> This was actually both an SQL and a php question.
>>>>>
>>>> Euhm, how is PHP involved again?
>>>> --
>>>> Rik Wasmus
>>> After getting the results, the looping through each record in order to
>>> output the results.
>> Bullshit. You can't rationalize your way out of this one, Shelly.
>
> Temper, temper. Easy now. No need to let your blood boil over what amounts
> to trivialities.
>
>> The question was a SQL question, and the answer was a SQL answer.
>>
>> Or, please tell me how "ORDER BY by deathdate" has ANYTHING to do with
>> PHP.
>
> Nothing. That line is pure SQL.
>
>> Or, where you had ANY PHP code in your answer.
>
> Look above. You get a resource from executing the query. If you don't
> agree that the reading the fields from each row of the result resource
> obtained from the query, or the continuous looping through that set till
> exhausted, or the output of each of these rows as html, is php, then we will
> simply have to agree to disagree.
>
> Shelly
>
>

I repeat. Where in "ORDER BY deathdate" has anything to do with PHP? I
don't see ANY sql in the PHP manual, for instance.

And where is the PHP code in your answer?

Or can't you tell the difference between SQL and PHP?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 07:36:03 von Macca

Just to insert some php in here to satisfy the die hards, in order to
display your ranking order you could do this:

$sql = "SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate
ASC";

$result = mysql_query($sql,$connection) or die(mysql_error());

for ($i=0; $i < mysql_num_rows($result); $i++){

$casualtyID = mysql_result($result,$i,"casualtyID");
$death_date = mysql_result($result,$i,"deathdate");
$rank = $i+=1;

echo "$casualtyID is the number $rank casualty to die in the current
wars in Iraq and Afghanistan\n";

}

Re: Ranking function in PHP/MySQL

am 07.10.2007 11:10:02 von Courtney

Rik Wasmus wrote:
> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
> wrote:
>> "Jerry Stuckle" wrote in message
>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>> Colleen wrote:
>>>> I'm trying to find out if there's a query/function similar to the RANK
>>>> function in Excel.
>>>> What I want to be able to do is take a list of dates from a particular
>>>> table field, and be able to rank each record in the order within which
>>>> in falls in those range of dates, because records are not always
>>>> entered in chronological order.
>>>> So, from this "ranking" query (that would generate the result $rank),
>>>> I want to be able to say:
>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>
>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>
>> This was actually both an SQL and a php question.
>>
>
> Euhm, how is PHP involved again?
Well it could have been: You could have done the sorting in php instead
of MySQL.

Re: Ranking function in PHP/MySQL

am 07.10.2007 13:55:40 von Shelly

"macca" wrote in message
news:1191735363.893427.245710@g4g2000hsf.googlegroups.com...
> Just to insert some php in here to satisfy the die hards, in order to
> display your ranking order you could do this:
>
> $sql = "SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate
> ASC";
>
> $result = mysql_query($sql,$connection) or die(mysql_error());
>
> for ($i=0; $i < mysql_num_rows($result); $i++){
>
> $casualtyID = mysql_result($result,$i,"casualtyID");
> $death_date = mysql_result($result,$i,"deathdate");
> $rank = $i+=1;
>
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
> }

Thanks, macca. I could have added that as well (and maybe then Jerry would
have shut up), but I wanted to leave **something** for the OP to do after I
put him/her on the right track. (BTW, I think you have a typo and meant
$i+1 and not $i+=1)

Shelly

Shelly

Re: Ranking function in PHP/MySQL

am 07.10.2007 13:58:01 von Shelly

Whatever.

"Jerry Stuckle" wrote in message
news:XYadnd2SidgIwpXanZ2dnUVZ_uLinZ2d@comcast.com...
> Shelly wrote:
>> "Jerry Stuckle" wrote in message
>> news:du2dnUdgBowD2JXanZ2dnUVZ_oLinZ2d@comcast.com...
>>> Shelly wrote:
>>>> "Rik Wasmus" wrote in message
>>>> news:op.tzsyi5zq5bnjuv@metallium.lan...
>>>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>>>> wrote:
>>>>>> "Jerry Stuckle" wrote in message
>>>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>>>> Colleen wrote:
>>>>>>>> I'm trying to find out if there's a query/function similar to the
>>>>>>>> RANK
>>>>>>>> function in Excel.
>>>>>>>> What I want to be able to do is take a list of dates from a
>>>>>>>> particular
>>>>>>>> table field, and be able to rank each record in the order within
>>>>>>>> which
>>>>>>>> in falls in those range of dates, because records are not always
>>>>>>>> entered in chronological order.
>>>>>>>> So, from this "ranking" query (that would generate the result
>>>>>>>> $rank),
>>>>>>>> I want to be able to say:
>>>>>>>> echo "$casualtyID is the number $rank casualty to die in the
>>>>>>>> current
>>>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>>> This was actually both an SQL and a php question.
>>>>>>
>>>>> Euhm, how is PHP involved again?
>>>>> --
>>>>> Rik Wasmus
>>>> After getting the results, the looping through each record in order to
>>>> output the results.
>>> Bullshit. You can't rationalize your way out of this one, Shelly.
>>
>> Temper, temper. Easy now. No need to let your blood boil over what
>> amounts to trivialities.
>>
>>> The question was a SQL question, and the answer was a SQL answer.
>>>
>>> Or, please tell me how "ORDER BY by deathdate" has ANYTHING to do with
>>> PHP.
>>
>> Nothing. That line is pure SQL.
>>
>>> Or, where you had ANY PHP code in your answer.
>>
>> Look above. You get a resource from executing the query. If you don't
>> agree that the reading the fields from each row of the result resource
>> obtained from the query, or the continuous looping through that set till
>> exhausted, or the output of each of these rows as html, is php, then we
>> will simply have to agree to disagree.
>>
>> Shelly
>
> I repeat. Where in "ORDER BY deathdate" has anything to do with PHP? I
> don't see ANY sql in the PHP manual, for instance.
>
> And where is the PHP code in your answer?
>
> Or can't you tell the difference between SQL and PHP?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 14:15:55 von Macca

>(BTW, I think you have a typo and meant
>$i+1 and not $i+=1)

My mistake. Easily done i suppose.

I dont understand why some of you people argue so much. If you dont
want to help on a post, why can't you just ignore it, instead of
making people feel unwelcome?

It's obvious from the poster's comment that they are new to php/MySQL
so may not know exactly where to ask for what. And since php and MySQL
are so closely linked, especially in what Colleen is trying to achieve
it didnt really hurt to ask here did it?

Regards,

Paul

Re: Ranking function in PHP/MySQL

am 07.10.2007 14:21:12 von Shelly

"macca" wrote in message
news:1191759355.687107.99880@g4g2000hsf.googlegroups.com...
>
>>(BTW, I think you have a typo and meant
>>$i+1 and not $i+=1)
>
> My mistake. Easily done i suppose.
>
> I dont understand why some of you people argue so much. If you dont
> want to help on a post, why can't you just ignore it, instead of
> making people feel unwelcome?
>
> It's obvious from the poster's comment that they are new to php/MySQL
> so may not know exactly where to ask for what. And since php and MySQL
> are so closely linked, especially in what Colleen is trying to achieve
> it didnt really hurt to ask here did it?
>
> Regards,
>
> Paul

I agree with you 100%. That is why I answered originally.

Shelly

Re: Ranking function in PHP/MySQL

am 07.10.2007 15:36:15 von Jerry Stuckle

macca wrote:
> Just to insert some php in here to satisfy the die hards, in order to
> display your ranking order you could do this:
>
> $sql = "SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate
> ASC";
>
> $result = mysql_query($sql,$connection) or die(mysql_error());
>
> for ($i=0; $i < mysql_num_rows($result); $i++){
>
> $casualtyID = mysql_result($result,$i,"casualtyID");
> $death_date = mysql_result($result,$i,"deathdate");
> $rank = $i+=1;
>
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
> }
>

The most stoopid argument I've seen in this group in ages.

The question was about how to do something in SQL. The answer was how
to do it in SQL.

Wrapping some stupid shit like this around it does not make it a PHP
question.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 15:37:56 von Jerry Stuckle

Shelly wrote:
> Whatever.
>

And you're so stoopid you quote a hole bunch of stuff just to top post
this one word.

Learn to post properly, stoopid. Both style and topic.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 15:43:34 von Jerry Stuckle

macca wrote:
>> (BTW, I think you have a typo and meant
>> $i+1 and not $i+=1)
>
> My mistake. Easily done i suppose.
>
> I dont understand why some of you people argue so much. If you dont
> want to help on a post, why can't you just ignore it, instead of
> making people feel unwelcome?
>
> It's obvious from the poster's comment that they are new to php/MySQL
> so may not know exactly where to ask for what. And since php and MySQL
> are so closely linked, especially in what Colleen is trying to achieve
> it didnt really hurt to ask here did it?
>
> Regards,
>
> Paul
>
>

Because this is a PHP newsgroup, and according to the charter, for *PHP*
questions.

Many of us want to keep this according to the charter - and not make it
a group for any question under the sun.

Unfortunately, there are a few idiots here who don't seen to understand
that. They need to stroke their egos by answering off-topic questions
instead of gently directing people to a more appropriate newsgroup.

For questions like this, comp.databases.mysql is much more appropriate.
They have *real* SQL experts hanging out there, not that wanna-be's we
see answering SQL questions here. And people who as questions will be
much better served by asking their SQL questions over there.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 15:45:13 von Jerry Stuckle

macca wrote:
>> (BTW, I think you have a typo and meant
>> $i+1 and not $i+=1)
>
> My mistake. Easily done i suppose.
>
> I dont understand why some of you people argue so much. If you dont
> want to help on a post, why can't you just ignore it, instead of
> making people feel unwelcome?
>
> It's obvious from the poster's comment that they are new to php/MySQL
> so may not know exactly where to ask for what. And since php and MySQL
> are so closely linked, especially in what Colleen is trying to achieve
> it didnt really hurt to ask here did it?
>
> Regards,
>
> Paul
>
>

Oh, and one other thing.

MySQL and PHP are not closely linked. They are only in the minds of
some programmers. MySQL is used with a lot of other languages. And PHP
uses a lot of other databases.

There is *NOTHING* closely linked about PHP and MySQL except a lot of
people use both products.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 15:45:52 von Jerry Stuckle

The Natural Philosopher wrote:
> Rik Wasmus wrote:
>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>> wrote:
>>> "Jerry Stuckle" wrote in message
>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>> Colleen wrote:
>>>>> I'm trying to find out if there's a query/function similar to the RANK
>>>>> function in Excel.
>>>>> What I want to be able to do is take a list of dates from a particular
>>>>> table field, and be able to rank each record in the order within which
>>>>> in falls in those range of dates, because records are not always
>>>>> entered in chronological order.
>>>>> So, from this "ranking" query (that would generate the result $rank),
>>>>> I want to be able to say:
>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>>
>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>
>>> This was actually both an SQL and a php question.
>>>
>>
>> Euhm, how is PHP involved again?
> Well it could have been: You could have done the sorting in php instead
> of MySQL.

And why reinvent the wheel?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 17:15:33 von Shelly

Gotcha! The top post was deliberate "stupid" and I quoted the "whole" text
on purpose as well. Now stop being such a whimpering child and grow up.

Shelly
P.S. This one too!


"Jerry Stuckle" wrote in message
news:V-Cdne5Aw6WkfJXanZ2dnUVZ_vvinZ2d@comcast.com...
> Shelly wrote:
>> Whatever.
>>
>
> And you're so stoopid you quote a hole bunch of stuff just to top post
> this one word.
>
> Learn to post properly, stoopid. Both style and topic.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 17:20:31 von Shelly

One more thing, Jerry, (and this is also a top post), I will, henceforth, no
longer respond to any post of yours. I have not resorted to name calling
when someone disagrees with me as you have. My previous answer was "if you
do not agree, then we will have to agree to disagree". Yes, I have called
you a whimpering child after you started with the "stoopid" stuff. However,
on second thought, I apologize for that and will take the more mature path
of no longer responding to you on any post, lest you go off again in a huff.
So Jerry, have a nice life.

Shelly

"Jerry Stuckle" wrote in message
news:V-Cdne5Aw6WkfJXanZ2dnUVZ_vvinZ2d@comcast.com...
> Shelly wrote:
>> Whatever.
>>
>
> And you're so stoopid you quote a hole bunch of stuff just to top post
> this one word.
>
> Learn to post properly, stoopid. Both style and topic.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 19:36:28 von Courtney

Shelly wrote:
> Gotcha! The top post was deliberate "stupid" and I quoted the "whole" text
> on purpose as well. Now stop being such a whimpering child and grow up.
>
Nocando. Look at where he's coming from.

Re: Ranking function in PHP/MySQL

am 07.10.2007 19:41:27 von Courtney

Jerry Stuckle wrote:

>
> The most stoopid argument I've seen in this group in ages.
>
TITLE="Ranking function in PHP/MySQL"
NEWSGROUP="comp.lang.php"

> The question was about how to do something in SQL.

No, it wasn't. The question was about how to od something in a mixed
PHP/MySQL environment.

It happens that you know its probably better tackled usng SQL. It may
not have been to the OP.


> The answer was how
> to do it in SQL.
>

It was, but that is only obvious if you know more than the poster did.

Or he would not have asked.

> Wrapping some stupid shit like this around it does not make it a PHP
> question.
>

And you claim to be a Christian?

I think I'll stick to atheism. You meet a nicer class of people. More
humble, more peacable, more charitable..;-)

Re: Ranking function in PHP/MySQL

am 07.10.2007 19:43:23 von Courtney

Jerry Stuckle wrote:
> The Natural Philosopher wrote:
>> Rik Wasmus wrote:
>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>> wrote:
>>>> "Jerry Stuckle" wrote in message
>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>> Colleen wrote:
>>>>>> I'm trying to find out if there's a query/function similar to the
>>>>>> RANK
>>>>>> function in Excel.
>>>>>> What I want to be able to do is take a list of dates from a
>>>>>> particular
>>>>>> table field, and be able to rank each record in the order within
>>>>>> which
>>>>>> in falls in those range of dates, because records are not always
>>>>>> entered in chronological order.
>>>>>> So, from this "ranking" query (that would generate the result $rank),
>>>>>> I want to be able to say:
>>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>>>
>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>
>>>> This was actually both an SQL and a php question.
>>>>
>>>
>>> Euhm, how is PHP involved again?
>> Well it could have been: You could have done the sorting in php
>> instead of MySQL.
>
> And why reinvent the wheel?
>
Because you didn't know there was a wheel already invented?
Because it is made out of materials you don't have to hand?
Because you LIKE inventing wheels?
Because none of the wheels immediatetly to hand fit your wagon?

I could go on..

Re: Ranking function in PHP/MySQL

am 07.10.2007 21:39:25 von Macca

>The most stoopid argument I've seen in this group in ages.
>The question was about how to do something in SQL. The answer was how
>to do it in SQL.

>Wrapping some stupid shit like this around it does not make it a PHP
>question.



Actually, yes it does. the OP wanted to know how to format the SQL
tsatement AND output the results, which unless I'm mistaken (which I'm
not) would be done with php.



>Many of us want to keep this according to the charter - and not make it
>a group for any question under the sun.


I would hardly call a php/MySQL question "any question under the sun"


>Unfortunately, there are a few idiots here who don't seen to understand
>that. They need to stroke their egos by answering off-topic questions
>instead of gently directing people to a more appropriate newsgroup.


It is not idiotic to help someone. That is partly what these
newsgroups are for. Nor does it have anything to do with "egos" and if
answering questions in newsgroups is just to stroke your ego then you
are doing it for the wrong reason.


>For questions like this, comp.databases.mysql is much more appropriate.
> They have *real* SQL experts hanging out there, not that wanna-be's we
>see answering SQL questions here. And people who as questions will be
>much better served by asking their SQL questions over there.


Maybe so, but what if you dont know what would be down to SQL and what
would be down to php? where would you ask? As the question obviously
involves both, here is a good a place as any.


>Oh, and one other thing.

>MySQL and PHP are not closely linked. They are only in the minds of
>some programmers. MySQL is used with a lot of other languages. And PHP
>uses a lot of other databases.

>There is *NOTHING* closely linked about PHP and MySQL except a lot of
>people use both products.


PHP and MySQL ARE closely linked in many ways. With PHP being the most
popular Open Source scripting language in the world, and MySQL being
the most popular Open Source RDBMS in the world, they are the most
likely combination when using PHP, and well documented in many LAMP
and php/mysql books and websites.

I did not say that they were EXCLUSIVELY RELATED, but they ARE closely
linked, with a myriad of specific MySQL functions built into php.


Anyway, I cant help but think you are getting too wound up about this.
It was a simple question with a simple answer which any in-the-know
php/sql developer could answer with ease , and did in this case by
helpful people like Shelly and myself.

Why people like you have to then come along ranting and raving and
swearing, even after the question has been answered is beyond me.

Re: Ranking function in PHP/MySQL

am 07.10.2007 21:50:35 von Jerry Stuckle

Shelly wrote:
> Gotcha! The top post was deliberate "stupid" and I quoted the "whole" text
> on purpose as well. Now stop being such a whimpering child and grow up.
>
> Shelly
> P.S. This one too!
>
>


What a stoopid asshole.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 21:56:35 von Jerry Stuckle

macca wrote:
>> The most stoopid argument I've seen in this group in ages.
>> The question was about how to do something in SQL. The answer was how
>> to do it in SQL.
>
>> Wrapping some stupid shit like this around it does not make it a PHP
>> question.
>
>
>
> Actually, yes it does. the OP wanted to know how to format the SQL
> tsatement AND output the results, which unless I'm mistaken (which I'm
> not) would be done with php.
>
>

The answer had nothing to do with PHP. It was strictly a SQL response.

>
>> Many of us want to keep this according to the charter - and not make it
>> a group for any question under the sun.
>
>
> I would hardly call a php/MySQL question "any question under the sun"
>

So where are you going to draw the line?
>
>> Unfortunately, there are a few idiots here who don't seen to understand
>> that. They need to stroke their egos by answering off-topic questions
>> instead of gently directing people to a more appropriate newsgroup.
>
>
> It is not idiotic to help someone. That is partly what these
> newsgroups are for. Nor does it have anything to do with "egos" and if
> answering questions in newsgroups is just to stroke your ego then you
> are doing it for the wrong reason.
>

It is idiotic not to direct someone to a more appropriate newsgroup
where they can get better answers for their questions.

>
>> For questions like this, comp.databases.mysql is much more appropriate.
>> They have *real* SQL experts hanging out there, not that wanna-be's we
>> see answering SQL questions here. And people who as questions will be
>> much better served by asking their SQL questions over there.
>
>
> Maybe so, but what if you dont know what would be down to SQL and what
> would be down to php? where would you ask? As the question obviously
> involves both, here is a good a place as any.
>

Ask by cross-posting to both newsgroups. Or accept a response that a
MySQL newsgroup would be a better place to ask, then ask over there.

>
>> Oh, and one other thing.
>
>> MySQL and PHP are not closely linked. They are only in the minds of
>> some programmers. MySQL is used with a lot of other languages. And PHP
>> uses a lot of other databases.
>
>> There is *NOTHING* closely linked about PHP and MySQL except a lot of
>> people use both products.
>
>
> PHP and MySQL ARE closely linked in many ways. With PHP being the most
> popular Open Source scripting language in the world, and MySQL being
> the most popular Open Source RDBMS in the world, they are the most
> likely combination when using PHP, and well documented in many LAMP
> and php/mysql books and websites.
>

Only in your mind. PHP is a programming language. MySQL is a database.
PHP can access MySQL - as it can PostGres, SQL Server, Access, Oracle,
DB2... So according to your theory, how to configure SQL Server is
also applicable here, because it can be accessed with PHP.

> I did not say that they were EXCLUSIVELY RELATED, but they ARE closely
> linked, with a myriad of specific MySQL functions built into php.
>

No more so than PHP is linked with any of the other databases noted
above, or indeed, many other products. And MySQL is no more closely
linked with PHP than it is with any other language.

>
> Anyway, I cant help but think you are getting too wound up about this.
> It was a simple question with a simple answer which any in-the-know
> php/sql developer could answer with ease , and did in this case by
> helpful people like Shelly and myself.
>
> Why people like you have to then come along ranting and raving and
> swearing, even after the question has been answered is beyond me.
>

Because some of us are tired of people encouraging off-topic questions
in this newsgroup.

Get it in your mind. This is comp.lang.php, not
comp.something.php-mysql. There is also a comp.databases.mysql.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 21:58:15 von Jerry Stuckle

Shelly wrote:
> One more thing, Jerry, (and this is also a top post), I will, henceforth, no
> longer respond to any post of yours. I have not resorted to name calling
> when someone disagrees with me as you have. My previous answer was "if you
> do not agree, then we will have to agree to disagree". Yes, I have called
> you a whimpering child after you started with the "stoopid" stuff. However,
> on second thought, I apologize for that and will take the more mature path
> of no longer responding to you on any post, lest you go off again in a huff.
> So Jerry, have a nice life.
>
> Shelly
>

Quite frankly, I don't give a damn if you respond or not. You have yet
to respond to anything I've asked.

But you continue to stroke your ego with off-topic responses, rather
than direct them to a more appropriate newsgroup.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 22:00:41 von Jerry Stuckle

The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> The Natural Philosopher wrote:
>>> Rik Wasmus wrote:
>>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>>> wrote:
>>>>> "Jerry Stuckle" wrote in message
>>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>>> Colleen wrote:
>>>>>>> I'm trying to find out if there's a query/function similar to the
>>>>>>> RANK
>>>>>>> function in Excel.
>>>>>>> What I want to be able to do is take a list of dates from a
>>>>>>> particular
>>>>>>> table field, and be able to rank each record in the order within
>>>>>>> which
>>>>>>> in falls in those range of dates, because records are not always
>>>>>>> entered in chronological order.
>>>>>>> So, from this "ranking" query (that would generate the result
>>>>>>> $rank),
>>>>>>> I want to be able to say:
>>>>>>> echo "$casualtyID is the number $rank casualty to die in the current
>>>>>>
>>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>>
>>>>> This was actually both an SQL and a php question.
>>>>>
>>>>
>>>> Euhm, how is PHP involved again?
>>> Well it could have been: You could have done the sorting in php
>>> instead of MySQL.
>>
>> And why reinvent the wheel?
>>
> Because you didn't know there was a wheel already invented?
> Because it is made out of materials you don't have to hand?
> Because you LIKE inventing wheels?
> Because none of the wheels immediatetly to hand fit your wagon?
>
> I could go on..

IOW, because you're stoopid?

I don't have a problem with the op asking the question here. But it
would have been much better to let them know that this is easily handled
in SQL, and point them to the appropriate SQL newsgroup.

But some people just don't get it. They think a newsgroup is their own
personal playground and the newsgroup charter doesn't apply to them.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 07.10.2007 23:31:50 von Bucky Kaufman

"The Natural Philosopher" wrote in message
news:1191779003.3824.1@proxy00.news.clara.net...
> Jerry Stuckle wrote:

>> And why reinvent the wheel?
>>
> Because you didn't know there was a wheel already invented?
> Because it is made out of materials you don't have to hand?
> Because you LIKE inventing wheels?
> Because none of the wheels immediatetly to hand fit your wagon?
>
> I could go on..

That was good.

Re: Ranking function in PHP/MySQL

am 08.10.2007 10:43:12 von Courtney

Jerry Stuckle wrote:
> The Natural Philosopher wrote:
>> Jerry Stuckle wrote:
>>> The Natural Philosopher wrote:
>>>> Rik Wasmus wrote:
>>>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>>>> wrote:
>>>>>> "Jerry Stuckle" wrote in message
>>>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>>>> Colleen wrote:
>>>>>>>> I'm trying to find out if there's a query/function similar to
>>>>>>>> the RANK
>>>>>>>> function in Excel.
>>>>>>>> What I want to be able to do is take a list of dates from a
>>>>>>>> particular
>>>>>>>> table field, and be able to rank each record in the order within
>>>>>>>> which
>>>>>>>> in falls in those range of dates, because records are not always
>>>>>>>> entered in chronological order.
>>>>>>>> So, from this "ranking" query (that would generate the result
>>>>>>>> $rank),
>>>>>>>> I want to be able to say:
>>>>>>>> echo "$casualtyID is the number $rank casualty to die in the
>>>>>>>> current
>>>>>>>
>>>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>>>
>>>>>> This was actually both an SQL and a php question.
>>>>>>
>>>>>
>>>>> Euhm, how is PHP involved again?
>>>> Well it could have been: You could have done the sorting in php
>>>> instead of MySQL.
>>>
>>> And why reinvent the wheel?
>>>
>> Because you didn't know there was a wheel already invented?
>> Because it is made out of materials you don't have to hand?
>> Because you LIKE inventing wheels?
>> Because none of the wheels immediatetly to hand fit your wagon?
>>
>> I could go on..
>
> IOW, because you're stoopid?
>
> I don't have a problem with the op asking the question here. But it
> would have been much better to let them know that this is easily handled
> in SQL, and point them to the appropriate SQL newsgroup.
>
> But some people just don't get it. They think a newsgroup is their own
> personal playground and the newsgroup charter doesn't apply to them.
>
>

That sounds like you allright.


>

Re: Ranking function in PHP/MySQL

am 08.10.2007 10:46:07 von Courtney

Jerry Stuckle wrote:
> Shelly wrote:
>> One more thing, Jerry, (and this is also a top post), I will,
>> henceforth, no longer respond to any post of yours. I have not
>> resorted to name calling when someone disagrees with me as you have.
>> My previous answer was "if you do not agree, then we will have to
>> agree to disagree". Yes, I have called you a whimpering child after
>> you started with the "stoopid" stuff. However, on second thought, I
>> apologize for that and will take the more mature path of no longer
>> responding to you on any post, lest you go off again in a huff. So
>> Jerry, have a nice life.
>>
>> Shelly
>>
>
> Quite frankly, I don't give a damn if you respond or not. You have yet
> to respond to anything I've asked.
>
> But you continue to stroke your ego with off-topic responses, rather
> than direct them to a more appropriate newsgroup.
>
>
I see you are a mirror man. One who sees his own faults in others, when
the fault lies within himself.

Now how does the Bible have it? "take the beam out of thine own eye
before thou seekest to take the mote from thy brothers?"


Apologies if its not word perfect. I have to go back 50 years to when
someone quoted it at me.

Re: Ranking function in PHP/MySQL

am 08.10.2007 14:02:39 von Jerry Stuckle

The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> Shelly wrote:
>>> One more thing, Jerry, (and this is also a top post), I will,
>>> henceforth, no longer respond to any post of yours. I have not
>>> resorted to name calling when someone disagrees with me as you have.
>>> My previous answer was "if you do not agree, then we will have to
>>> agree to disagree". Yes, I have called you a whimpering child after
>>> you started with the "stoopid" stuff. However, on second thought, I
>>> apologize for that and will take the more mature path of no longer
>>> responding to you on any post, lest you go off again in a huff. So
>>> Jerry, have a nice life.
>>>
>>> Shelly
>>>
>>
>> Quite frankly, I don't give a damn if you respond or not. You have
>> yet to respond to anything I've asked.
>>
>> But you continue to stroke your ego with off-topic responses, rather
>> than direct them to a more appropriate newsgroup.
>>
>>
> I see you are a mirror man. One who sees his own faults in others, when
> the fault lies within himself.
>

Talking about yourself again? Typical troll. My ego needs no stroking,
and I don't answer off-topic questions here.

> Now how does the Bible have it? "take the beam out of thine own eye
> before thou seekest to take the mote from thy brothers?"
>

You should pay attention to what you read, troll.

>
> Apologies if its not word perfect. I have to go back 50 years to when
> someone quoted it at me.

Maybe you should actually read it then, instead of trying to remember a
50 year old quote.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 08.10.2007 14:05:36 von Jerry Stuckle

The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> The Natural Philosopher wrote:
>>> Jerry Stuckle wrote:
>>>> The Natural Philosopher wrote:
>>>>> Rik Wasmus wrote:
>>>>>> On Sun, 07 Oct 2007 00:20:12 +0200, Shelly
>>>>>> wrote:
>>>>>>> "Jerry Stuckle" wrote in message
>>>>>>> news:QI6dnSmjxJezY5ranZ2dnUVZ_v_inZ2d@comcast.com...
>>>>>>>> Colleen wrote:
>>>>>>>>> I'm trying to find out if there's a query/function similar to
>>>>>>>>> the RANK
>>>>>>>>> function in Excel.
>>>>>>>>> What I want to be able to do is take a list of dates from a
>>>>>>>>> particular
>>>>>>>>> table field, and be able to rank each record in the order
>>>>>>>>> within which
>>>>>>>>> in falls in those range of dates, because records are not always
>>>>>>>>> entered in chronological order.
>>>>>>>>> So, from this "ranking" query (that would generate the result
>>>>>>>>> $rank),
>>>>>>>>> I want to be able to say:
>>>>>>>>> echo "$casualtyID is the number $rank casualty to die in the
>>>>>>>>> current
>>>>>>>>
>>>>>>>> Next time, please post your SQL questions to a MySQL newsgroup.
>>>>>>>
>>>>>>> This was actually both an SQL and a php question.
>>>>>>>
>>>>>>
>>>>>> Euhm, how is PHP involved again?
>>>>> Well it could have been: You could have done the sorting in php
>>>>> instead of MySQL.
>>>>
>>>> And why reinvent the wheel?
>>>>
>>> Because you didn't know there was a wheel already invented?
>>> Because it is made out of materials you don't have to hand?
>>> Because you LIKE inventing wheels?
>>> Because none of the wheels immediatetly to hand fit your wagon?
>>>
>>> I could go on..
>>
>> IOW, because you're stoopid?
>>
>> I don't have a problem with the op asking the question here. But it
>> would have been much better to let them know that this is easily
>> handled in SQL, and point them to the appropriate SQL newsgroup.
>>
>> But some people just don't get it. They think a newsgroup is their
>> own personal playground and the newsgroup charter doesn't apply to them.
>>
>>
>
> That sounds like you allright.
>
>
>>

No, assholes and trolls don't get it. And you're both.

You could read the charter for this newsgroup. And understand the
purpose for which it was approved to be created.

But that's assuming you can read, which we know you can't. And that you
can understand simple language, which we know you can't either.

But you do think this is your own personal playground.

Hell, you've even admitted you aren't a programmer. So why do you
bother hanging around except to stroke your ego?

At least some people here actually help others with on-topic questions.
I have yet to see you do anything useful.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Ranking function in PHP/MySQL

am 08.10.2007 17:09:02 von Mladen Gogala

On Sat, 06 Oct 2007 18:16:01 +0000, Colleen wrote:

> Hello!
>
> I've only been dabbling in PHP and MySQL for a few months.
>
> I'm trying to find out if there's a query/function similar to the RANK
> function in Excel.
>
> What I want to be able to do is take a list of dates from a particular
> table field, and be able to rank each record in the order within which
> in falls in those range of dates, because records are not always entered
> in chronological order.
>
> Here's a partial sampling of my table, showing the relevant fields for
> this query.
>
> casualtyID deathdate
> 1 2003-12-01
> 2 2007-06-20
> 3 2002-08-30
> 4 2007-01-01
> 5 2005-04-11
>
> So, from this "ranking" query (that would generate the result $rank), I
> want to be able to say:
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
>
> Thank you!
>
> Colleen Robledo
> http://www.colleenrobledo.info

I'm not sure about MySQL but Oracle can do the following:
select id,
dense_rank() over (order by deathdate) as rnk
from table;

You can do that on the classic EMP table and it goes like this:


1 select ename,hiredate,
2 dense_rank() over (order by hiredate) as rnk
3* from emp
SQL> /

ENAME HIREDATE RNK
---------- --------- ----------
SMITH 17-DEC-80 1
ALLEN 20-FEB-81 2
WARD 22-FEB-81 3
JONES 02-APR-81 4
BLAKE 01-MAY-81 5
CLARK 09-JUN-81 6
TURNER 08-SEP-81 7
MARTIN 28-SEP-81 8
KING 17-NOV-81 9
JAMES 03-DEC-81 10
FORD 03-DEC-81 10
MILLER 23-JAN-82 11
SCOTT 19-APR-87 12
ADAMS 23-MAY-87 13

14 rows selected.

SQL>


You can do that with Oracle Express, too. It's called "analytic function".

--
http://www.mladen-gogala.com

Re: Ranking function in PHP/MySQL

am 08.10.2007 17:14:01 von Mladen Gogala

On Sat, 06 Oct 2007 18:20:12 -0400, Shelly wrote:

> This was actually both an SQL and a php question.

Nope, it isn't. It's just a problem with SQL.



--
http://www.mladen-gogala.com

Re: Ranking function in PHP/MySQL

am 08.10.2007 17:15:28 von phpCodeHead

On Oct 7, 10:20 am, "Shelly" wrote:
> One more thing, Jerry, (and this is also a top post), I will, henceforth, no
> longer respond to any post of yours. I have not resorted to name calling
> when someone disagrees with me as you have. My previous answer was "if you
> do not agree, then we will have to agree to disagree". Yes, I have called
> you a whimpering child after you started with the "stoopid" stuff. However,
> on second thought, I apologize for that and will take the more mature path
> of no longer responding to you on any post, lest you go off again in a huff.
> So Jerry, have a nice life.
>
> Shelly
>
> "Jerry Stuckle" wrote in message
>
> news:V-Cdne5Aw6WkfJXanZ2dnUVZ_vvinZ2d@comcast.com...
>
> > Shelly wrote:
> >> Whatever.
>
> > And you're so stoopid you quote a hole bunch of stuff just to top post
> > this one word.
>
> > Learn to post properly, stoopid. Both style and topic.
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================

Follow this thread... Left to right, top to bottom and ask your
self... Did that make any sense?

Come on, who's really being childish here?

Now....

The original post was absolutely, 100% SQL query building question.
How do I "take a list of dates from a particular table field, and be
able to rank each record in the order within which in falls in those
range of dates" could apply to any RDBMS system; but how is PHP (the
subject of this newsgroup) to do that? Through MySQL, Oracle, or MSSQL
functions!

The resulting recordset could be handled by any number of programming
languages.

What is the harm in posting the original question here, in a PHP
related newsgroup? Well, if say, 2 or 3 months from now, whenever I or
any other programmer on the planet is in search of an answer similar
to Colleen's; do you think that search will begin in a PHP newsgroup?

In fact the only point to which I disagree with Jerry is that it
certainly doesn't belong in a MySQL newsqroup. It should actually be
posted in a most generic SQL newsgroup.

The proof of evidence in justifying our requests lies in your very
answer to Colleen's question. Was the answer not a simple SQL
statement that can be executed by any number of RDBMS systems and then
further process upon by any number of programming language?

For the betterment of ALL users of the usenet system, at least TRY to
put a little thought in to where to post your queries...

Thanx...

Re: Ranking function in PHP/MySQL

am 08.10.2007 22:56:02 von Jerry Stuckle

phpCodeHead wrote:
> On Oct 7, 10:20 am, "Shelly" wrote:
>> One more thing, Jerry, (and this is also a top post), I will, henceforth, no
>> longer respond to any post of yours. I have not resorted to name calling
>> when someone disagrees with me as you have. My previous answer was "if you
>> do not agree, then we will have to agree to disagree". Yes, I have called
>> you a whimpering child after you started with the "stoopid" stuff. However,
>> on second thought, I apologize for that and will take the more mature path
>> of no longer responding to you on any post, lest you go off again in a huff.
>> So Jerry, have a nice life.
>>
>> Shelly
>>
>> "Jerry Stuckle" wrote in message
>>
>> news:V-Cdne5Aw6WkfJXanZ2dnUVZ_vvinZ2d@comcast.com...
>>
>>> Shelly wrote:
>>>> Whatever.
>>> And you're so stoopid you quote a hole bunch of stuff just to top post
>>> this one word.
>>> Learn to post properly, stoopid. Both style and topic.
>>> --
>>> ==================
>>> Remove the "x" from my email address
>>> Jerry Stuckle
>>> JDS Computer Training Corp.
>>> jstuck...@attglobal.net
>>> ==================
>
> Follow this thread... Left to right, top to bottom and ask your
> self... Did that make any sense?
>
> Come on, who's really being childish here?
>
> Now....
>
> The original post was absolutely, 100% SQL query building question.
> How do I "take a list of dates from a particular table field, and be
> able to rank each record in the order within which in falls in those
> range of dates" could apply to any RDBMS system; but how is PHP (the
> subject of this newsgroup) to do that? Through MySQL, Oracle, or MSSQL
> functions!
>
> The resulting recordset could be handled by any number of programming
> languages.
>
> What is the harm in posting the original question here, in a PHP
> related newsgroup? Well, if say, 2 or 3 months from now, whenever I or
> any other programmer on the planet is in search of an answer similar
> to Colleen's; do you think that search will begin in a PHP newsgroup?
>
> In fact the only point to which I disagree with Jerry is that it
> certainly doesn't belong in a MySQL newsqroup. It should actually be
> posted in a most generic SQL newsgroup.
>
> The proof of evidence in justifying our requests lies in your very
> answer to Colleen's question. Was the answer not a simple SQL
> statement that can be executed by any number of RDBMS systems and then
> further process upon by any number of programming language?
>
> For the betterment of ALL users of the usenet system, at least TRY to
> put a little thought in to where to post your queries...
>
> Thanx...
>

I have no argument that a generic SQL newsgroup might be more
appropriate, also. However, unfortunately, SQL is not SQL is not SQL.
Different databases implement it differently, which is why I recommended
comp.databases.mysql.

But either would be good.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================