同一个SQL查询视图表多次查询返回结果不同

Viewed 3

查询的表是视图表

dws.dws_v_dcsp_const_proj_output_val_daily 这是一个视图表, 有多个视图表合成的

同一个SQL, 查询多次, 返回数据不一致

MySQL [(none)]>  select sum(
    ->       case when list_is_tax_included_code=1 then nvl(month_plan_const_output_val,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end)*0.0001
    ->              else nvl(month_plan_const_output_val_excl_tax,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end) * 0.0001 end
    ->              ) as ybz_byjh
    ->  from  dws.dws_v_dcsp_const_proj_output_val_daily
    ->  where curr_cycle='2025-03-01' and lv3_corp_shortname='三公司';


+--------------------+
| ybz_byjh           |
+--------------------+
| 60548.577694000000 |
+--------------------+
1 row in set (5.125 sec)

MySQL [(none)]>
MySQL [(none)]>
MySQL [(none)]>  select sum(
    ->       case when list_is_tax_included_code=1 then nvl(month_plan_const_output_val,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end)*0.0001
    ->              else nvl(month_plan_const_output_val_excl_tax,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end) * 0.0001 end
    ->              ) as ybz_byjh
    ->  from  dws.dws_v_dcsp_const_proj_output_val_daily
    ->  where curr_cycle='2025-03-01' and lv3_corp_shortname='三公司';


+--------------------+
| ybz_byjh           |
+--------------------+
| 56613.599494000000 |
+--------------------+
1 row in set (4.481 sec)

MySQL [(none)]>
MySQL [(none)]>
MySQL [(none)]>  select sum(
    ->       case when list_is_tax_included_code=1 then nvl(month_plan_const_output_val,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end)*0.0001
    ->              else nvl(month_plan_const_output_val_excl_tax,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end) * 0.0001 end
    ->              ) as ybz_byjh
    ->  from  dws.dws_v_dcsp_const_proj_output_val_daily
    ->  where curr_cycle='2025-03-01' and lv3_corp_shortname='三公司';


+--------------------+
| ybz_byjh           |
+--------------------+
| 65378.577694000000 |
+--------------------+
1 row in set (4.173 sec)

MySQL [(none)]>
MySQL [(none)]>
MySQL [(none)]>  select sum(
    ->       case when list_is_tax_included_code=1 then nvl(month_plan_const_output_val,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end)*0.0001
    ->              else nvl(month_plan_const_output_val_excl_tax,0) * (case when cny_code='156' THEN 1 ELSE 7.116285 end) * 0.0001 end
    ->              ) as ybz_byjh
    ->  from  dws.dws_v_dcsp_const_proj_output_val_daily
    ->  where curr_cycle='2025-03-01' and lv3_corp_shortname='三公司';


+--------------------+
| ybz_byjh           |
+--------------------+
| 61713.599494000000 |
+--------------------+
1 row in set (4.036 sec)

MySQL [(none)]>
0 Answers