kennyTE
07-19-2007, 07:39 PM
i have a table looks like this (sales_man_id)
---------------------
(id)(sales_man_id)(set_target_sales)(achieve_sales)
1 5004 1000 5
2 5005 1000 8
3 5006 1000 2
4 5007 1000 2
5 5008 500 2
6 5009 500 1
---------------------
i want to find out only 5 salesman where achieve_sales is not hit base on the set_target_sales and achieve_sales where is smallest. So that i can call 5 selected salesman to do the new sales for tomorrow.
my sql queries looks like this:
---------------------
SELECT sales_man_id FROM
sales_person
WHERE set_target_sales > achieve_sales
ORDER BY achieve_sales
LIMIT 5
----------------------
it return from the query as:
sales_man_id
5008
5009
what happen, and how? suppose i want the query return :
sales_man_id
5009
5008
5007
5006
5004
what i do wrong with my sql, can some one teach me how?
---------------------
(id)(sales_man_id)(set_target_sales)(achieve_sales)
1 5004 1000 5
2 5005 1000 8
3 5006 1000 2
4 5007 1000 2
5 5008 500 2
6 5009 500 1
---------------------
i want to find out only 5 salesman where achieve_sales is not hit base on the set_target_sales and achieve_sales where is smallest. So that i can call 5 selected salesman to do the new sales for tomorrow.
my sql queries looks like this:
---------------------
SELECT sales_man_id FROM
sales_person
WHERE set_target_sales > achieve_sales
ORDER BY achieve_sales
LIMIT 5
----------------------
it return from the query as:
sales_man_id
5008
5009
what happen, and how? suppose i want the query return :
sales_man_id
5009
5008
5007
5006
5004
what i do wrong with my sql, can some one teach me how?