hi,
I have face a problem many times to build some complex reports in crystal report that need some group by column and also have some ungroup columns.
For example, let i have a table of that structure
in which i want to group data according to Areacode,AreaName,AreaRank and also want to sum of TeamCollection with other fields also such as LocalAreaCode ,LocalAreaRank, and there is one condition for having only those reords which have CollectionPer >=100 for each areacode and arearank=9 and creatdate= '11/14/2009' .
Here is sql query that provide me corect data.
SELECT a.AreaCode, a.AreaName, a.AreaRank, a.CreatDate, a.LocalAreaCode, a.LocalAreaRank, a.SelfCollection, a.TeamCollection, a.CreatDate AS CreatDate ,
a.CollectionPer
FROM tbl_AreaCollection AS a INNER JOIN
(SELECT DISTINCT AreaCode
FROM tbl_AreaCollection
GROUP BY AreaCode
HAVING (SUM(CollectionPer) >= 100)) AS b ON a.AreaCode = b.AreaCode AND a.CreatDate = '11/14/2009' AND a.AreaRank = 9
ORDER BY a.AreaCode
here is the output
Comments
Post a Comment