Listbox crazyness

Argonak

Registered User.
Local time
Today, 10:56
Joined
Apr 15, 2005
Messages
28
Hi, I've got a listbox which is being used to display some data. When I hit a button I want it to resort the data its displaying. I do this with the "ORDER BY" in the query as below:

Code:
SELECT  item_id_est, descr_est, mtrl_itm, size_itm, Round(Sum(quantity_est),0) As 'Quantity', um_itm, Round(Sum(quantity_est*pm_ur_est)/sum(quantity_est),3) AS 'PM_Rate', Round(Sum(quantity_est*pm_ur_est),0) AS 'PM_Total', Round(Sum(quantity_est*labor_ur_est)/sum(quantity_est),3) AS 'Labor_Rate', Round(Sum(quantity_est*labor_ur_est), 0) AS 'Labor_Total', Round(Sum(sub_val_est),0) As 'Sub', Round(Sum(engr_val_est),0) As 'Equip' FROM estimates_tble INNER JOIN item_tbl ON item_id_est = item_id_itm WHERE job_name_est = 'AECI Full' AND mtrl_itm = 'c1' GROUP BY item_id_est, descr_est, mtrl_itm, size_itm, um_itm  ORDER BY  size_itm

Code:
SELECT  item_id_est, descr_est, mtrl_itm, size_itm, Round(Sum(quantity_est),0) As 'Quantity', um_itm, Round(Sum(quantity_est*pm_ur_est)/sum(quantity_est),3) AS 'PM_Rate', Round(Sum(quantity_est*pm_ur_est),0) AS 'PM_Total', Round(Sum(quantity_est*labor_ur_est)/sum(quantity_est),3) AS 'Labor_Rate', Round(Sum(quantity_est*labor_ur_est), 0) AS 'Labor_Total', Round(Sum(sub_val_est),0) As 'Sub', Round(Sum(engr_val_est),0) As 'Equip' FROM estimates_tble INNER JOIN item_tbl ON item_id_est = item_id_itm WHERE job_name_est = 'AECI Full' AND mtrl_itm = 'c1' GROUP BY item_id_est, descr_est, mtrl_itm, size_itm, um_itm  ORDER BY  descr_est

The problem is that after I even though I'm copying the entireity of the statement except for the last word, its returning an entirely different result. And now that I've looked into it, NEITHER result is correct, both are leaving out a lot of stuff.

I've got other listboxes which have 8000 or so rows and are made up of more columns, yet I can't figure out why this one won't display the 100 or so rows I'm asking for. Anyone have any ideas?
 
Well, I think I got it figured out, one of my entries is dividing by a sum, and in some rare cases that sum would be 0. Which would be a divide by zero, and instead of throwing an error, I think it was just not returning results after that. So now I do a <> 0 for quantity, and that seems to have eliminated the problem.
 

Users who are viewing this thread

Back
Top Bottom