SQL语句问题
来源:互联网 发布:读文学作品的软件 编辑:程序博客网 时间:2024/05/18 02:47
以前写SQL时一直很生硬的写着一条一条。效率很低。因为它不能有效的结合在一起。今天尝试了一下。果然可以。也让我欣喜万分,特意拿来与大家共同分享。但是有些认为我是菜鸟的话,也不要笑话我哦。谢谢。
select t1.IDas ID,max(t2.Col1) as Col1,Max(t2.Col2) as Col2,sum(Col3) AS Col3,sum(Col4) AS Col4,Convert(numeric(5,2),avg(Col5)) AS Col5, sum(Col6) AS Col6,sum(Col7) AS Col7,sum(Col8) AS Col8,(select top 1 Col9 from BasIncrDeclaMonthVeri where BasIncrDeclaMonthVeri.ItemID=t1.ItemID order by EnYear desc,EnMonth desc) AS Col9 ,
(select top 1 Col10 from BasIncrDeclaMonthVeri where BasIncrDeclaMonthVeri.ItemID=t1.ItemID order by EnYear desc,EnMonth desc) AS Col10
from BasIncrDeclaMonthVeri t1 left join BasEnteBasicInfo t2 on t1.ItemID=t2.ItemID
where t1.Status='1'
group by t1.ID
在select sum(),sum(),from table1 里可以加一个select语句,这样更好的把结果放到datagrid 或gridview里面。
- sql语句长度问题
- sql语句问题
- SQL语句大小写问题
- SQL语句问题
- sql语句优化问题
- SQL 语句问题
- sql语句排序问题
- sql语句的问题
- SQL语句--排名问题。
- oralce sql语句问题
- sql语句问题汇总
- sql语句查询问题
- ibatis sql语句问题
- SQL语句过长换行问题!
- sql语句遇到的问题
- Access中Sql语句问题
- SQl语句的效率问题
- sql语句换行的问题
- VBA 判断Word进程是否存在和当前word文档是否打开
- Pro T-SQL 2005 Programmer's Guide (Expert's Voice)
- Web Publishing with PHP and FileMaker 9
- Hide Your SSDT HOOK
- 十句箴言
- SQL语句问题
- 计算一下从result=1+2+……+100的结果
- Foundations of SQL Server 2005 Business Intelligence
- spring WEB MVC + Spring + hibernate开发web程序的配置说明和简单实例的详细说明
- listview用法
- Access Data Analysis Cookbook
- Linux For Dummies 8th Edition
- SQL Server 2000 Database Design and Implementation
- Portable DBA: SQL Server