当前位置: 代码迷 >> Sql Server >> 不同客户端浏览器访问同一张报表值不一样解决思路
  详细解决方案

不同客户端浏览器访问同一张报表值不一样解决思路

热度:89   发布时间:2016-04-27 14:01:26.0
不同客户端浏览器访问同一张报表值不一样
我们公司使用的是Sqlserver2008 Report Services,最近发现有个异常一直困扰我很久,就是有一张报表被不同客户端电脑的浏览器同一时刻访问时,有一个数据项值竟然不一样有时相差几百或者上千,该值是统计一个特定条件的会员人数,值为400W左右。请问这是什么问题造成的,如何处理,谢谢?

是不是我的Sql脚本有问题,我里面要实现这样一个思路,统计3个值,再将这3个值加起来,展现在报表中,脚本如下:
是不是我的Sql脚本有问题,我里面要实现这样一个思路,统计3个值,再将这3个值加起来,展现在报表中,脚本如下:
DECLARE @begin_date AS DATETIME
DECLARE @end_date AS DATETIME
DECLARE @end_date2 AS DATETIME
SET @begin_date='2012-01-01'
SET @end_date='2012-01-31'
SET @end_date2=GETDATE()
--DECLARE @end_date2 DATETIME
--SET @end_date2 = GETDATE()
---所有有交易的会员
DECLARE @a_num AS INT 
DECLARE @b_num AS INT
DECLARE @c_num AS INT 
SET @a_num=0;
SET @b_num=0;
SET @c_num=0;
--所有有交易有会员资料的
SELECT @a_num = COUNT(distinct a.account_number )
from account a 
left join declaration d on a.account_id=d.account_id
left join place on d.place_id=place.place_id and place.active_flag=1
left join admincity ad ON ad.admincity_id = place.admincity_id
where 1=1
and (a.is_test_account!=1 or a.is_test_account is null)
--and place.active_flag=1 and ad.used_flag=1
AND (d.is_destroyed_flag IS NULL OR is_destroyed_flag != 1)
--AND d.purchase_date<@end_date2 
AND CONVERT(CHAR(10),d.purchase_date,120)<CONVERT(CHAR(10),@end_date2 ,120)
AND d.processed <> 'Q' ---

--有交易没有会员资料的
select @b_num = COUNT(distinct d.temp_ref_account_number)
from declaration d 
left join place on d.place_id=place.place_id and place.active_flag=1
left join admincity ad ON ad.admincity_id = place.admincity_id
where 1=1 AND d.temp_ref_account_number IS NOT NULL AND d.account_id IS NULL 
and place.active_flag=1 and ad.used_flag=1
AND (d.is_destroyed_flag IS NULL OR is_destroyed_flag != 1)
--AND d.purchase_date<@end_date2 
AND CONVERT(CHAR(10),d.purchase_date,120)<CONVERT(CHAR(10),@end_date2 ,120)
AND d.processed <> 'Q'---;
--有交易没有会员资料的
select @c_num = COUNT(DISTINCT t.account_code )
from transaction_import t 
left join place on t.place_code=place.place_code and place.active_flag=1
left join admincity ad ON ad.admincity_id = place.admincity_id
where t.process_status <> 1 AND t.process_status <> 10
and t.account_code in (select account_number from card_no_gen where t.account_code=account_number)
and t.account_code not in (select membershipID from testmember) 
--AND t.transaction_date<@end_date2;
AND CONVERT(CHAR(10),t.transaction_date,120)< CONVERT(CHAR(10),@end_date2 ,120);

WITH cte AS --有交易的会员
(
  SELECT '有交易的会员' AS Member_Type,(@[email protected][email protected]_num) AS Total,'' AS 'Member%'
)
SELECT * FROM cte
 


------解决方案--------------------
浏览器只是起到浏览的作用,不理解楼主描述的问题是怎么发生的?
------解决方案--------------------
同时访问造成的?
------解决方案--------------------
没有处理好并发问题吧
------解决方案--------------------
为什么要把日期转换成字符在进行比较呢?是不是这里出问题了,不同机器日期转换后的格式不同造成的?


------解决方案--------------------
探讨
浏览器只是起到浏览的作用,不理解楼主描述的问题是怎么发生的?

------解决方案--------------------
探讨
为什么要把日期转换成字符在进行比较呢?是不是这里出问题了,不同机器日期转换后的格式不同造成的?
  相关解决方案