All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
asp.net2.0两句代码搞定文件上传_[Asp.Net教程]
ASP.Net中保护自定义的服务器控件_.net资料_编程技术
.NET内置对象之Cookie对象_[Asp.Net教程]
关于PHP字符集的问题_php资料_编程技术
dropdownlist,datagrid数据绑定简单实现_[Asp.Net教程]
用PHP程序直接调用文本文件内容分析_php资料_编程技术
.net精简框架集下的ini文件读取
LINQ体验系列文章导航_[Asp.Net教程]
SQL Server 索引基础知识(1)--- 记录数据的基本格式_[SQL Server教程]
SQL,Server,7.0,入门(五)_mssql学习_编程技术
Reading number is top 10 pictures
China telecom 114 spokesman MeiYanXu2
Beauty ZhiHuiLin1
Absolutely shocked. National geographic 50 animal photographys1
Wear bikinis cock
The real super beauty13
The service WaLiangGe Chinese aircraft carrier1
2012 national geographic daily picture3
青春清纯美女大集合1
The money of more than 100 countries and regions16
In 2013 hercules Arnold classic2
Download software ranking
White deer villiage
都市狐狸姑娘传
Sora aoi, the nurse, uniform ,nursing assistant
Desire a peach blossom
Dance with duck(male prostitution)
VC++6.0简体中文版
The Bermuda triangle3
虚拟机汉化软件
Ashlynn Video4
Tram sex maniac 2 (H) rar bag14
归海一刀 published in(发表于) 2014/2/1 0:23:36 Edit(编辑)
菜鸟到高手:SQL开发进阶常用精妙语句_[SQL,Server教程]

菜鸟到高手:SQL开发进阶常用精妙语句_[SQL,Server教程]

菜鸟到高手:SQL开发进阶常用精妙语句_[SQL Server教程]

如何从一位菜鸟蜕变成为高手,灵活使用的SQL语句是必不可少的。本文收集了部分比较经典,常用的SQL语句供大家参考,希望对大家有所帮助。

说明:复制表(只复制结构,源表名:a 新表名:b)  

SQL: select * into b from a where 1<>1

说明:拷贝表(拷贝数据,源表名:a 目标表名:b)  

SQL: insert into b(a, b, c) select d,e,f from b;

说明:显示文章、提交人和最后回复时间  

SQL: select a.title,a.username,b.adddate

from table a,(select max(adddate) adddate

from table where table.title=a.title) b

说明:外连接查询(表名1:a 表名2:b)  

SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c

说明:日程安排提前五分钟提醒  

SQL: select * from 日程安排 where datediff('minute',f开始时间,getdate())>5  

说明:两张关联表,删除主表中已经在副表中没有的信息

SQL:   

delete from info

where not exists ( select * from infobz where info.infid=infobz.infid

说明:--

SQL:


 SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE 
  FROM TABLE1,
   (SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE
   FROM (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND
   FROM TABLE2
   WHERE TO_CHAR(UPD_DATE,'YYYY/MM') = TO_CHAR(SYSDATE, 'YYYY/MM')) X,
   (SELECT NUM, UPD_DATE, STOCK_ONHAND
   FROM TABLE2
   WHERE TO_CHAR(UPD_DATE,'YYYY/MM') =
   TO_CHAR(TO_DATE(TO_CHAR(SYSDATE, 'YYYY/MM') ¦¦ '/01','YYYY/MM/DD') - , 'YYYY/MM') Y,
  WHERE X.NUM = Y.NUM (+)
   AND X.INBOUND_QTY + NVL(Y.STOCK_ONHAND,0) <> X.STOCK_ONHAND B
  WHERE A.NUM = B.NUM

说明:--

SQL:   

 select * from studentinfo where not exists(select * from student where studentinfo.id=student.id) and 系名称='"&strdepartmentname&"' and 专业名称='"&strprofessionname&"' order by 性别,生源地,高考总成绩

说明:

从数据库中去一年的各单位电话费统计(电话费定额贺电化肥清单两个表来源)

SQL:  


  SELECT a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy') AS telyear, 
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '01', a.factration)) AS JAN,
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '02', a.factration)) AS FRI,
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '03', a.factration)) AS MAR,
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '04', a.factration)) AS APR,
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '05', a.factration)) AS MAY,
   SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '06', a.factration)) AS JUE,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '07', a.factration)) AS JUL,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '08', a.factration)) AS AGU,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '09', a.factration)) AS SEP,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '10', a.factration)) AS OCT,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '11', a.factration)) AS NOV,
  SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '12', a.factration)) AS DEC
  FROM (SELECT a.userper, a.tel, a.standfee, b.telfeedate, b.factration
   FROM TELFEESTAND a, TELFEE b
   WHERE a.tel = b.telfax) a
  GROUP BY a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy')



说明:四表联查问题:  

SQL: select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c


inner join d on a.a=d.d where .....

说明:得到表中最小的未使用的ID号

SQL:


  SELECT (CASE WHEN EXISTS(SELECT * FROM Handle b WHERE b.HandleID = 1) 
THEN MIN(HandleID) + 1 ELSE 1 END) as HandleID 
   FROM Handle
   WHERE NOT HandleID IN (SELECT a.HandleID - 1 FROM Handle a)






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.