专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Informix

百分求解informix下合并两个SQL语句,多谢~

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
百分求解informix下合并两个SQL语句,谢谢~~~~~~~~
由于编写程序的要求需要在INFORMIX下将以下两条SQL合并为一条SQL,求高手相助!!

select claim_folder_no,max(estimate_no) estimate_no from auto_estimated_l01 group by 1 into temp aaa with no log;

select sum(estimate_amount) amount from auto_estimated_l01 b,aaa a,auto_claim_folde01 f where b.claim_folder_no=f.claim_folder_no
 and a.claim_folder_no=b.claim_folder_no and a.estimate_no=b.estimate_no
 and (f.case_STATUS='0' or (f.case_STATUS in ('1','2','3') and date(f.CLOSING_DATE) >'11/30/2008')) and date(f.OPENING_DATE)<='11/30/2008';

------解决方案--------------------
应该实现不了,informix不支持同一个sql对同一张表进行嵌套查询,楼主的两个sql中均包含auto_estimated_101表。楼主可以这样试一下,先执行sql1生成临时表aaa,然后执行sql2,如可正常执行,则如我红色部分所说。其实用一个太复杂的sql语句实现并不复杂的功能并不是最好的方法,完全可以通过两条清晰的sql实现此功能,我觉得这样步骤更清晰,思路也更清晰。
------解决方案--------------------
如果是找出所有 claim_folder_no,最大estimate_no的SUM值。
SQL code
select sum(estimate_amount) amount 
from auto_estimated_l01 a
where not exists (select estimate_no from auto_estimated_l01 where claim_folder_no=a.claim_folder_no and estimate_no>a.estimate_no);

------解决方案--------------------
你将
select claim_folder_no,max(estimate_no) estimate_no from auto_estimated_l01 group by 1
生成视图试试
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

  • asp 连接informix出错解决方案

    asp 连接informix出错 asp 连接informix出错。odbc test connection成功。 出错提示: “Microsoft OLE DB Provider for ODBC...

  • 怎么提高查询效率

    如何提高查询效率 表架构: 主表+明细表,明细数据按月存储,即: 主表:wamia 明细:wamia201001 wamia201002 …… 目标: 1、...

  • 询问下informix的价格,该如何处理

    询问下informix的价格 想问下关于windows下informix choice版11.5和11.7的价格大概是多少啊?按CPU算的 ------解决方案----------...

  • informix与db2,该如何处理

    informix与db2 informix与db2,应该学哪个? ------解决方案-------------------- 那要看你工作的需要了。 以及以后客户的需要...

  • sqexplain.out 怎么分析

    sqexplain.out 如何分析? SQL code Table map : ---------------------------- Internal name Table name ---------...

  • informix建表,该怎么处理

    informix建表 有个时间想取系统当前时间 怎么设啊? SQL code create table s ( start time --想要是系统当前时间,怎么设置? ) ---...

  • informix -271异常

    informix -271错误 1、谁有 informix 授权号啊,能不能帮忙送一个啊??先借我用一下啊!!邮箱是:lymusic2007@126.com 万分感激!!! 或者请...

  • 急答案,送分,关于Informix SQL 字符转ASCII码

    急!急!在线等答案,送分,关于Informix SQL 字符转ASCII码 各位高手,在Informix数据库中,怎样把char字符获取它的ASCII码值?看起来好像很简...

  • 请问informix存储过程调用远端数据库方法

    请教informix存储过程调用远端数据库方法 我现在想实现从另一台机器上的informix数据库的表中取数,插入到本地的表中, 数据量大概...

  • informix 存储过程中数据类型有关问题,

    informix 存储过程中数据类型问题,急。。。。 目的想实现的是从数据库中把数据取出来放到一个单元格中查出来,每条记录用","格开。 ...

热门推荐: