Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sort from subreport? Post Reply Post New Topic
Author Message
matt1361
Newbie
Newbie


Joined: 07 Nov 2007
Location: United States
Online Status: Offline
Posts: 17
Quote matt1361 Replybullet Topic: Sort from subreport?
     Posted: 14 Jan 2008 at 1:35pm
Hi,
 
Is it possible to sort data in the main report from data that is contained in the Sub Report? 
I am trying to sort by state for the very last delivery date on each truck.  I have only been able to pull the last delivery date for each truck by using the maximum function in a subreport.
 
Thanks


Edited by matt1361 - 14 Jan 2008 at 3:21pm
IP IP Logged
matt1361
Newbie
Newbie


Joined: 07 Nov 2007
Location: United States
Online Status: Offline
Posts: 17
Quote matt1361 Replybullet Posted: 16 Jan 2008 at 10:47am
I am guessing since there are no replies that this not possible or is not an easy task.
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 16 Jan 2008 at 10:09pm
hi
 i have tried this lot of times, but unfortunately its not possible to sort the data on the value returned from subreport.
Thanks
Savan
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 17 Jan 2008 at 4:58am
As a further note, though, it is possible to do this through SQL.  It requires some extra gymnastics, and may slow down your report.  But it is possible.


SELECT OriginalQuery.*, ForOrder.DeliveryState
FROM OriginalQuery
JOIN (
    SELECT DelMain.TruckID, DelMain.DeliveryState
    FROM Delivery DelMain
    JOIN (
       SELECT TruckID, MAX(DeliveryDate) AS MaxDate
       FROM Delivery
       GROUP BY TruckID) DelSub
    ON DelMain.TruckID = DelSub.TruckID
    AND DelMain.DeliveryDate = DelSub.MaxDate) ForOrder
ON OriginalQuery.TruckID = ForOrder.TruckID


Obviously, you will have to modify that for your own values.  But, hopefully that will give you an idea of the structure you need to follow.  You can then sort on Delivery State.


IP IP Logged
matt1361
Newbie
Newbie


Joined: 07 Nov 2007
Location: United States
Online Status: Offline
Posts: 17
Quote matt1361 Replybullet Posted: 17 Jan 2008 at 8:18am
This is Fantastic!  Thanks for helping me with this road block.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum