Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 SUM of fields is wrong

Author  Topic 

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-02-21 : 17:15:49
I vhae a column that is in the third grouping on a report, it is supposed to =SUM(Fields!ddp_weight.Value,"PickupDate")

the column in the report query is
40575
40575
40575
40575
40575
40575
40575
40575
40575
40575
40575
12952
12952
12952
12952
12952
12952
12952
12952
12952
61867
61867
61867
748494 SUM that is being returned instead of

40575
12952
61867
115394 SUM that shoule be returned

I am comparing that SUM with another colomn in the same grouping that is returning the correct value.

Any clues



Thanks for the help
CoachBarker

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-22 : 01:15:28
how is your dataset now? what all fields does it contain?
Go to Top of Page

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-02-22 : 09:00:43
This is my query

SELECT detail_record.ticket_number, detail_record.division, detail_record.pickup_weight, CAST(detail_record.pickup_dt AS datetime) AS PickupDate,
CAST(detail_record.deliver_dt AS datetime) AS DeliverDate, detail_record.customer_delv_to, detail_record.customer_bill_to,
cmBillTo.customer_number AS bill_to_number, cmBillTo.customer_name AS bill_to_name, cmBillTo.city AS bill_to_city,
cmDelvTo.customer_number AS deliver_to_number, cmDelvTo.customer_name AS deliver_to_name, cmDelvTo.city AS deliver_to_city,
detail_record.pickup_date, detail_record.grand_total_wt, hauler_master.hauler_number, detail_record.ddp_weight AS LoadPounds
FROM detail_record INNER JOIN
customer_master AS cmBillTo ON detail_record.customer_bill_to = cmBillTo.customer_number INNER JOIN
customer_master AS cmDelvTo ON detail_record.customer_delv_to = cmDelvTo.customer_number INNER JOIN
hauler_master ON detail_record.hauler_number = hauler_master.hauler_number
WHERE (detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_bill_to = @customer_number) OR
(detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_delv_to = @customer_number)
ORDER BY detail_record.pickup_date


There are 5 groups in this report customer_bill_to, customer_delv_to, ticket_number, PickupDate and division.

The actual query returns all the correct data. Maybe I am grouping the fields in the wrong order?

What is the difference between table level grouping and details grouping?
Thanks for the help
CoachBarker
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-23 : 03:15:40
SELECT DISTINCT?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-02-23 : 06:12:47
But won't distinct effect all repeating data returned from the query? Say I have multiple dates that are 09/01/2008 it will only select one of them when I need all of them?

I think I have figured out the problem, I was trying to get a sum that was in a group one level lower.

Again thank you for your assistance.

Thanks for the help
CoachBarker
Go to Top of Page
   

- Advertisement -