Can any one tell me if using Group By in a query coming into a report will effect the Order By.When I use this query i can not get the report to Order By the fields I want (each report has to be able to sort by three different fields) and I use this query to get the SUM of the LoadPounds which has repeating values:SELECT detail_record.ticket_number AS TicketNumber, cmDelvTo.customer_number AS DeliverToNumber, cmDelvTo.customer_name AS DeliverToName, cmDelvTo.city AS DeliverToCity, cmBillTo.customer_number AS BillToNumber, cmBillTo.customer_name AS BillToName, cmBillTo.city AS BillToCIty, CAST(detail_record.pickup_dt AS datetime) AS PickupDate, CAST(detail_record.deliver_dt AS datetime) AS DeliverDate, SUM(detail_record.pickup_weight) AS PickupPounds, detail_record.hauler_number AS HaulerNumber, SUM(DISTINCT detail_record.ddp_weight) AS LoadPounds, detail_record.deliver_dateFROM 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_numberWHERE (detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_delv_to = @customer_number) OR (detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_bill_to = @customer_number)GROUP BY cmBillTo.customer_number, cmBillTo.customer_name, cmBillTo.city, cmDelvTo.customer_number, cmDelvTo.customer_name, cmDelvTo.city, detail_record.pickup_dt, detail_record.ticket_number, detail_record.deliver_dt, detail_record.hauler_number, detail_record.deliver_dateORDER BY TicketNumber
But if I use this query I can sort by any field I want to:SELECT detail_record.ticket_number AS TicketNumber, cmDelvTo.customer_number AS DeliverToNumber, cmDelvTo.customer_name AS DeliverToName, cmDelvTo.city AS DeliverToCity, cmBillTo.customer_number AS BillToNumber, cmBillTo.customer_name AS BillToName, cmBillTo.city AS BillToCIty, CAST(detail_record.pickup_dt AS datetime) AS PickupDate, CAST(detail_record.deliver_dt AS datetime) AS DeliverDate, detail_record.pickup_weight AS PickupPounds, detail_record.hauler_number AS HaulerNumber, detail_record.ddp_weight AS LoadPounds, detail_record.deliver_dateFROM 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_numberWHERE (detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_delv_to = @customer_number) OR (detail_record.pickup_date BETWEEN @start_date AND @end_date) AND (detail_record.customer_bill_to = @customer_number)
I have checked in the properties and set the report to sort by the correct fields and the sort order for each Group using both queries.Thanks for the helpCoachBarker