Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping on Summary Data

Status
Not open for further replies.

LizRuss

Technical User
Apr 23, 2004
7
GB
Hi,

I am using CR9 and need to display data grouped by a count.

i.e. customers 1,3,5,7,9 have made 1 order
customers 2,4,6,8 have made 2 orders.

My report needs to be grouped on the number of orders that have been made.

So it would look like

1 Order:

Customer 1,
3,
5,
7,
9

2 Orders:

Customer 2,
4,
6,
8

Please advise :)

For a better way of life check out
 
Crystal only lets you group on values based on individual records, not summaries.

You can use 'Top n' to put groups in a desired sequence. Does that help?

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Is the Order actually a field

eg.

Cust Order

1 2
3 1
4 2
6 1

if so simply group by the Order fields first and then by Customer.

If not could you tell me how do you get the order generated.

Mo
 
You could do it in SQL

Code:
select CustomerId, Count(order_id) as Orders
from dbo.yourtable
group by CustomerId
this way you can group by it from crystal.

Mo
 
You could try creating a SQL expression {%ordercnt}:

(Select count(A.`OrderID`) from Table A where
A.`CustomerID` = Table.`CustomerID`)

The punctuation differs based on your datasource, so check your "Show SQL Query" to get an idea of what yours should be like. If your CR 9.0 accepts this, you can then insert a group on {%ordercnt}. Otherwise you can build this expression into a query by using "Add Command" as your datasource. Your query would look something like:

Select
Table.`CustomerID`, ((Select count(A.`OrderID`) from Table A where A.`CustomerID` = Table.`CustomerID`)
From
`Table` Table

Again, you would be able to use the resulting expression to group on.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top