如何在Crystal报表中打印每10条记录的总计 [英] How to print the each 10 records total in crystal report

查看:77
本文介绍了如何在Crystal报表中打印每10条记录的总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
早安,

我的Crystal报表有问题,在我的Crystal报表中,我打印了200个客户的NetSale,因此我需要将NetSale字段总计放在每10个客户之后.例如

客户NetSale
Cust1 112
cust2 12
cust3 14
....
...
....
...
cust10 80
----------------------
总计=(净销售额的10以上的总和)
---------------------------
cust11 63
cust12 82
cust13 73
....
....
...
....
cust20 87
---------------------------
total =(cust11到cust20 NetSale值的总和)

cust21
..
....
...

请帮助我......
谢谢..

Dear All,
Good morning,

I have issues with Crystal report,In my crystal report i printing 200 of Customer''s NetSale,so i need to put NetSale field total after Each 10 customer.for example

customer NetSale
Cust1 112
cust2 12
cust3 14
....
...
....
...
cust10 80
----------------------
total=(sum of above 10 value of netsale)
---------------------------
cust11 63
cust12 82
cust13 73
....
....
...
....
cust20 87
---------------------------
total=(sum of cust11 to cust20 NetSale value)

cust21
..
....
...

please help me ......
thanks..

推荐答案

我认为您需要在数据源端解决此问题.

如果您在报表中使用SQL语句:
除非数据库中没有某些列,否则您可以将记录分成十组,我认为您可以通过在每10条记录中添加一个唯一的数字并使用此数字在Crystal Report中创建子总计来解决. >
使用SQL ROW_NUMBER [天花板 [
I think you will need to solve this at the data source end.

If you are using SQL statement in your report:
Unless you have some column in your database you can use to split the records in groups of ten I think you can solve this by adding a unique number to every 10 records and using this number to create a sub total in Crystal Report.

Use SQL ROW_NUMBER[^] to assign a unique number to each record.
Divide this number by 10 and use CEILING[^] to round the number up.
This should give the first 10 records number 1 and the next 10 records number 2, etc.
Now use this column to create the sub totals for every 10 records.

I have no time to test this, so I am not 100% sure it will work but give it a try.
I have tested it and it works, use the below statements.

Create and populate table:
CREATE TABLE Customer
(Name CHAR(8),
 Sale INTEGER DEFAULT 0)
 
DECLARE @counter INTEGER
SET @counter = 1
WHILE @counter <= 100
BEGIN
	INSERT INTO Customer VALUES ('CUST' + REPLICATE('0', 4-LEN(@counter)) + CONVERT(CHAR(4), @counter), ABS(CAST(CAST(NEWID() AS VARBINARY) AS INTEGER)) % 10000)

	SET @counter = @counter + 1
END



根据Name创建一个10人一组:



Create groups of 10 based on the Name:

SELECT CEILING(ROW_NUMBER() OVER(ORDER BY Name)/10.0) AS GroupID, Name, Sale
FROM Customer
ORDER BY Name


这篇关于如何在Crystal报表中打印每10条记录的总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆