Sql 中 Exists 的应用
来源:互联网 发布:上市公司财务报表数据 编辑:程序博客网 时间:2024/06/04 18:57
select distinct ttt.PRJ,ttt.CCTR from (
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '08' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060811
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
union all
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '03' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060311
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
) as ttt
where exists (
select tt.CCTR ,Count(tt.CCTR ) from (
select distinct t.CCTR ,t.PRJ from (
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '08' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060811
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
union all
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '03' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060311
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
) as t
) as tt
where ttt.CCTR =tt.CCTR
group by tt.CCTR
having COUNT(tt.CCTR )>=2
)
- Sql 中 Exists 的应用
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists、not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- sql中exists,not exists的用法
- 测试程序运行时间的方法
- 一些VC插件的简介
- Visual C++文件后缀名释义
- Spring管理
- 用c#中的RichTextBox实现图文格式编排存储和格式化显示
- Sql 中 Exists 的应用
- 使用visualvm远程监控JVM
- EJB
- eclipse3.2快捷键设置
- .live()已经弃用!
- Tomcat java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
- Cross compiling wxDFB-2.8.11 for ARM-Linux
- VC++编写ActiveX控件
- 命名规则