perfectchaoss
Programmer
Code:
SELECT TOP 5 PERCENT dbo_FormReportSS.UPC, dbo_FormReportSS.ItemDesc, dbo_FormReportSS.WhseNum, dbo_FormReportSS.PriceOnly, dbo_FormReportSS.CaseCost, dbo_FormReportSS.UnitsCase, dbo_FormReportSS.UnitCost, dbo_FormReportSS.[GM%], Sum(dbo_FormReportSS.LstWght) AS SumOfLstWght, Sum(dbo_FormReportSS.LstMvmtCt) AS SumOfLstMvmtCt, Sum(dbo_FormReportSS.Sales) AS SumOfSales, dbo_FormReportSS.Brand, dbo_FormReportSS.CommCode, dbo_FormReportSS.DSDVendor
FROM dbo_FormReportSS
WHERE (((dbo_FormReportSS.aisleloc) Like "*" & [Forms]![DeptMinorSS]![cboAisle] & "*") AND ((dbo_FormReportSS.Date)>=[Forms]![DeptMinorSS]![txtStartDate] And (dbo_FormReportSS.Date)<=[Forms]![DeptMinorSS]![txtEndDate]) AND ((dbo_FormReportSS.DeptNum)=[Forms]![DeptMinorSS]![cboDepartment]) AND ((dbo_FormReportSS.CommCode) Like [Forms]![DeptMinorSS]![cboCommCode]))
GROUP BY dbo_FormReportSS.UPC, dbo_FormReportSS.ItemDesc, dbo_FormReportSS.WhseNum, dbo_FormReportSS.PriceOnly, dbo_FormReportSS.CaseCost, dbo_FormReportSS.UnitsCase, dbo_FormReportSS.UnitCost, dbo_FormReportSS.[GM%], dbo_FormReportSS.Brand, dbo_FormReportSS.CommCode, dbo_FormReportSS.DSDVendor
HAVING (((dbo_FormReportSS.UPC) Like "*" & [Forms]![DeptMinorSS]![txtUPC] & "*") AND ((dbo_FormReportSS.DSDVendor) Like "*" & [Forms]![DeptMinorSS]![cboVendor] & "*"))
ORDER BY Sum(dbo_FormReportSS.Sales);
Rows returned when code is ran = 1308
Rows returned when Percent is changed to 100 = 1765
1308/1765 = 74%
Another note when i run this exact same code except DESCENDING (DESC) it returns the correct number of row's to be 5% of the total rowcount (89). 89/1765 = 5%
My logic is telling me that sorting the Query should not effect how many rows are returned, does anyone have any ideas why this is happening. Ive tried changing from ASC to DESC on simple queries with a SELECT TOP 5 PERCENT and it works exactly how it should.
Thanks,
Joe