精典SQL语句
分类统计总数并排序多表联合查询的两种方法
例:
查询地区表中各省下面城市总数,并对查询结果取前十名
法一:
select b.id,a.[name],b.counts from n_area a,(select top 10 parent_id as id,sum(parent_id) as counts from n_area where parent_id<>0 group by parent_id order by sum(parent_id) desc
) b where a.id=b.id
法二:
select top 10 a.id,a.[name],(select count(*) from n_area b where b.parent_id=a.id ) as counts from n_area a where a.parent_id=0 order by counts desc
例:
查询发贴表中回复数最多的前十条发贴,(发帖与回帖同一表,查询出发帖主题,发帖ID,发帖人(另表),回帖数)
select a.mid,a.mtitle,(select c.uimg from BBS_Power c where c.uid=a.uid and c.uclass=a.uclass) as img from BBS_Msg a,(select top 10 partenID as id,sum(partenID) as counts from BBS_Msg where partenID<>0 group by partenID order by sum(partenID) desc) b where a.mid=b.id
相关文档:
在“新建”菜单中,有Program window,Test window,SQL window和Command window等。
SQL window和Command window有什么区别??
Command window实现了SQL*Plus的所有功能,允许运行sql*plus命令,sql命令,sql脚本。
SQL window用于执行sql语句,显示sql输出,执行统计信息。(测试sql语句,查看表中的数据, ......
胡辉:13028803715 0755-82945017
9、深圳microsoft Windows 2003 Server报价 中文标准版5用户 4100
10、深圳microsoft Windws 2003 Server报价 中文企业版25用户 20500
11、深圳microsoft Windows 2008 Server报价 中文标准版5用户 580 ......
一、基础
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database dbname
3、说明:备份sql server
--- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- 开始 备份
BACKUP DATABASE pubs TO testBack
4、说 ......
原文链接:http://blog.btidea.com/article.asp?id=440
查询速度慢的原因很多,常见如下几种:
1、没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷)
2、I/O吞吐量小,形成了瓶颈效应。
3、没有创建计算列导致查询不优化。
4、内存不足
5、网络 ......
<%
set conn= server.createobject("ADODB.connection")
conn.open "driver={sybase driver 10};"
"srvr=SYBASE;"
"UID=sa;"
"pwd=sybase;"
sql="select no from tab_st ......