OZONE Asylum
Forums
Server-Side Scripting - Oh my!
MySQL sum() help
This page's ID:
31099
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Good afternoon. Having a little trouble with a query I am running. The premise: I have a database tracking deliveries. I need to get a summary by week of particular information associated with the deliveries. The SQL code I am using is as follows: [code] select week(Schedule.del_date) as week_num, sum(SKU.sku_ctn) as ctns_total, sum(SKU.sku_vol) as vol_total, count(distinct SKU.sku_num) as sku_total, count(distinct PO.po_num) as po_total, count(distinct Vend.vnd_name) as vnd_total, count(distinct Bill.hbl_num) as hbl_total, count(distinct Container.cnt_id) as cnt_total from Schedule left join Container on Container.cnt_id = Schedule.cnt_id left join Bill on Bill.cnt_id = Container.cnt_id left join Vend on Vend.cnt_id = Bill.cnt_id left join PO on PO.cnt_id = Vend.cnt_id left join SKU on SKU.cnt_id = PO.cnt_id where Container.sts_id = 4 group by week_num order by week_num asc [/code] This pulls me out a nice array containing, for each week, the week number and a summary of the deliveries for that week. --> Except that both items that I need to sum() are incorrect. The count()'s are all accurate. The sum()'s are not - they are off by very large amounts (double, triple, or more). They don't appear to be off in any sort of discernible pattern, or with any particular relationship that I can follow. I am not sure what to look at as the cause of the error - any thoughts??
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail