【发布时间】:2015-08-22 00:34:20
【问题描述】:
我在网上搜索,发现很多人有同样的问题,但没有一个解决方案适合我。 我真的希望你能帮助我: 我有这个在 PL/SQL 中运行良好的 ORACLE SQL 查询:
select a.bzq_terminate_provider, a.callsnum, a.at_call_dur_sec, sum_charge
From (select * from usage_cycle_sum
where ban='80072922' and ben='1'
and subscriber_no='036585305'
and start_cycle_code ='20150207'
and feature_code_rank='1') a, (select bzq_terminate_provider,sum(charge_amount) as sum_charge from usage_cycle_sum
where ban='80072922' and ben='1'
and subscriber_no='036585305'
and start_cycle_code ='20150207' group by bzq_terminate_provider) b
where a.bzq_terminate_provider=b.bzq_terminate_provider
我也尝试了这个也可以正常工作的其他版本:
select PROVIDER,sum(CALLS),sum(CHARGE),sum(DUR)
from (
select bzq_terminate_provider PROVIDER,callsnum CALLS,charge_amount CHARGE,at_call_dur_sec DUR
from usage_cycle_sum
where ban='80072922' and ben='1'
and subscriber_no='036585305'
and start_cycle_code ='20150207'
and feature_code_rank='1'
union
select bzq_terminate_provider PROVIDER,0 CALLS,charge_amount CHARGE,0 DUR
from usage_cycle_sum
where ban='80072922' and ben='1'
and subscriber_no='036585305'
and start_cycle_code ='20150207'
and feature_code_rank='2'
)
group by PROVIDER
我的问题是,当我在 Visual Studio Web 应用程序中创建数据网格时,出现错误:语法错误:需要标识符或引用标识符
连接正常,我检查了简单的选择查询以及我附加的第二个查询中的整个联合部分,它们有效! 但是当我使用这两个版本时,我得到了这个错误。
可能是什么问题?还有其他方法可以解决这个问题吗? 谢谢。
编辑 21/06/2015 似乎 Visual Studio 不能很好地处理复杂的查询,我仍在寻找解决方案,因为我的下一个查询更复杂......
【问题讨论】:
-
您可以尝试在子查询之后放置一个表别名。也许连接过程中的某些东西需要这个,因为许多数据库都这样做(并且可能 ODBC 有这个要求)。
标签: sql asp.net oracle visual-studio syntax-error