Jump to content

Ordering Question


aconnal

Recommended Posts

Hi, I'm new to the board so please be gentle with me.

Anyway I seem to have a problem, I am creating a league table for sales people, I have got it doing everything I want apart from one thing, the ordering.

My script creates a temporary table and then I extract the information from that table and order it by the total of sales, however the ordering is wrong this is how it is ordering the total of sales at the moment:

9675
2140
18790??

Surely the 18790 should be at the top? It looks like mysql is ordering the numbers by the first number and not the whole value!!

Any thoughts on this would be appriciated.

Thanks

A
Link to comment
Share on other sites

Cool, here is the code to create the temporary table:

$CREATE = "CREATE TEMPORARY TABLE temp_total_sales(total_sale_id int(10) NOT NULL AUTO_INCREMENT, salesperson_id int(10) NOT NULL, total_sales char(50) NOT NULL, PRIMARY KEY(total_sale_id))";

mysql_query($CREATE) or die(mysql_error());

Here is the query to extract the information:

$QUERY3 = "SELECT * FROM temp_total_sales ORDER BY total_sales DESC";
$RESULT3 = mysql_query($QUERY3) or die(mysql_error());
$NUMRESULTS3 = mysql_numrows($RESULT3);

Hope this helps.

Cheers

A
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.