[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
ʵ¼ÊÓ¦ÓÃÖÐÎÒÃÇ¿ÉÒÔͨ¹ýsum()ͳ¼Æ³ö×éÖеÄ×ܼƻòÕßÊÇÀÛ¼ÓÖµ£¬¾ßÌåʾÀýÈçÏ£º
1.´´½¨ÑÝʾ±í
create table emp
as
select * from scott.emp;
alter table emp
add constraint emp_pk
primary key(empno);
create table dept
as
select * from scott.dept;
alter table dept
add constraint dept_pk
primary key(deptno);
2. sum()Óï¾äÈçÏ£º
select deptno,
ename,
sal,
¡¡¡¡--°´ÕÕ²¿ÃÅнˮÀÛ¼Ó£¨order by¸Ä±äÁË·ÖÎöº¯ÊýµÄ×÷Óã¬Ö»¹¤×÷ÔÚµ±Ç°ÐкÍÇ°Ò»ÐУ¬¶ø²»ÊÇËùÓÐÐУ©
sum(sal) over (partition by deptno order by sal) CumDeptTot,
sum(sal) over (partition by deptno) SalByDept, --ͳ¼ÆÒ»¸ö²¿ÃŵÄнˮ
sum(sal) over (order by deptno,sal) CumTot, --ËùÓйÍÔ±µÄнˮһÐÐÒ»ÐеÄÀÛ¼Ó
sum(sal) over () TotSal --ͳ¼Æ×Üнˮ
from emp
order by deptno, sal
3. ½á¹ûÈçÏ£º
10 MILLER 1300.00 1300 8750 1300 29025
10 CLARK 2450.00 3750 8750 3750 29025
10 KING 5000.00 8750 8750 
Ïà¹ØÎĵµ£º
ÎÒÃÇÔÚÊý¾Ý¿âÖÐʹÓñíµÄʱºò,¾³£»áÓöµ½Á½ÖÖʹÓñíµÄ·½·¨,·Ö±ð¾ÍÊÇʹÓÃÁÙʱ±í¼°±í±äÁ¿¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ÎÒÃÇÈçºÎÁé»îµÄÔÚ´æ´¢¹ý³ÌÖÐÔËÓÃËüÃÇ£¬ËäÈ»ËüÃÇʵÏֵŦÄÜ»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬¿ÉÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÓÐʱºòȥʹÓÃÁÙʱ±í¶ø²»Ê¹Óñí±äÁ¿£¬ÓÐʱºòȥʹÓñí±äÁ¿¶ø²»Ê¹ÓÃÁÙʱ±íÄØ?
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ±íÓëÓÀ¾Ã± ......
----start
Ç°Ã棬ÎÒÃǽéÉÜÁË ¾¡Á¿±ÜÃâÔÚSQLÓï¾äµÄWHERE×Ó¾äÖÐʹÓú¯Êý£¬ÒòΪÕâÑù×ö»áʹ¸Ã×Ö¶ÎÉϵÄË÷ÒýʧЧ£¬Ó°ÏìSQLÓï¾äµÄÐÔÄÜ¡£»ùÓÚͬÑùµÄµÀÀí£¬ÎÒÃÇÒ²Ó¦¸Ã±ÜÃâʹÓÃLIKE¡£¿¼ÂÇÏÂÃæµÄÇé¿ö£º
CREATE TABLE USER
(
NAME VARCHAR(20) NOT NULL,---ÐÕÃû
MYNUMBER VARCHAR(18)---Éí·ÝÖ¤ºÅÂë
);&nb ......
ϵͳ»·¾³£ºwindows xp pro
Êý¾Ý¿â£ºMS Sql 2000
IIS: 5.1 ASP.NET2.0
ÒòΪ´úÂëÊÇ2.0.netµÄ,ûÓа취ֻºÃ°²×°ÁË.netÏÂÔØÄã¿ÉÒÔȥ΢ÈíµÄÍøÕ¾ÉÏÈ¥ÏÂÔØ.Õâ¸öÊÇÃâ·ÑµÄÈí¼þ£¬ÎÒÖªµÀµÄÊÇÃâ·ÑµÄ¡£
Êý¾Ý¿â×öÁËѹËõºó׺ÊÇbakµÄ£¬ËùÒÔÊý¾Ý¿â²»ÄÜÖ±½ÓʹÓã¬ÐèÒªµ¼ÈëÔÚÍøÉϲéÁ˺ܶàµÄ×ÊÁϵ«ÊDz»¶à£¬µ«×Ô¼º³É¹¦µ¼ÈëÁË£¬Ð´ÏÂÀ´×öÒ»¸ö±¸ ......
/*
ʹÓÃÊÂÎñÈÕÖ¾»Ö¸´Êý¾ÝµÄʵÑé
*/
--1.´´½¨²âÊÔÊý¾Ý¿â
CREATE DATABASE Db_test
ON
( NAME = Db_test_DATA,
FILENAME = 'c:\Db_test.mdf' )
LOG ON
( NAME = Db_test_LOG,
FILENAME = 'c:\Db_test.ldf')
GO
--2.¹ÊÕÏ»¹ÔÄ£ÐÍÉèÖÃΪfullÄ£ÐÍ,ĬÈϵļòµ¥Ä£Ðͱ¸·Ý ......
1.ÔÚ²éѯ·ÖÎöÆ÷ϲéѯExcelÎĵµ
Select * from
OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source = "c:\²âÊÔ.xls";User ID = Admin;Password=;Extended properties=Excel8.0)....Sheet1$
2.´ÓÊý¾Ý¿âÖе¼³öÊý¾Ý²¢´æµ½ÎļþÖÐ
EXEC master..xp_cmdshell 'bcp CAS2004..HGZ_LIAOJIAN out c:\temp1.xls -c -q -S"."- ......