一些有用的sql语句实例

2009-05-12 20:20:55来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

1Examples


=======================================

selectid,age,FullnamefromtableOnea
wherea.id!=(selectmax(id)fromtableOnebwherea.age=b.ageanda.FullName=b.FullName)

=========================================

deletefromdbo.Schedulewhere

RoomID=29andStartTime>'2005-08-08'andEndTime<'2006-09-01'andRemarklike'preset'andUserID=107

and(

(ScheduleID>=3177andScheduleID<=3202)

or(ScheduleID>=3229andScheduleID<=3254)

or(ScheduleID>=3307andScheduleID<=3332)

=========================================

deletetableOne
wheretableOne.id!=(selectmax(id)fromtableOnebwheretableOne.age=b.ageandtableOne.FullName=b.FullName);

==========================================

DataClient12/23/20055:03:38PM

selecttop5

DOC_MAIN.CURRENT_VERSION_NOasVersion,DOC_MAIN.MODIFY_DATEasModifyDT,DOC_MAIN.SUMMARYasSummary,DOC_MAIN.AUTHOR_EMPLOYEE_NAMEasAuthorName,DOC_MAIN.TITLEasTitle,DOC_MAIN.DOCUMENT_IDasDocumentID,Attribute.ATTRIBUTE_IDasAttributeId,Attribute.CATALOG_IDasCatalogId,DOC_STATISTIC.VISITE_TIMESasVisiteTimes,DOC_STATISTIC.DOCUMENT_IDasDocumentID2

fromDOC_MAINDOC_MAIN

InnerjoinCATALOG_SELF_ATTRIBUTEAttributeonDOC_MAIN.CATALOG_ID=Attribute.CATALOG_ID

LeftjoinDOC_STATISTICDOC_STATISTIConDOC_MAIN.DOCUMENT_ID=DOC_STATISTIC.DOCUMENT_ID

where(DOC_MAIN.AUTHOR_EMPLOYEE_ID=1)and(Attribute.ATTRIBUTE_ID=11)

orderbyVisiteTimesDESC

====================================

selecttop1DOCUMENT_ID,EMPLOYEE_NAME,COMMENT_DATE,COMMENT_VALUE

fromdbo.DOC_COMMENT

whereDOCUMENT_ID=19andCOMMENT_DATE=(selectmax(COMMENT_DATE)fromDOC_COMMENTwhereDOCUMENT_ID=19)

====================================

selectTITLE,(selecttop1EMPLOYEE_NAME

fromdbo.DOC_COMMENTwhereDOCUMENT_ID=19)Commentman,

(selecttop1COMMENT_DATE

fromdbo.DOC_COMMENTwhereDOCUMENT_ID=19)COMMENT_DATE

fromDOC_MAINwhereDOCUMENT_ID=19

======================================

alterviewExpertDocTopComment

as

selectDOCUMENT_ID,max(ORDER_NUMBER)aslastednum

fromdbo.DOC_COMMENT

groupbyDOCUMENT_ID

go

alterviewExpertDocView

as

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:MYSQL使用简述

下一篇:枚举SQLServer的实例