sql server 2008 示例数据库教程sql语句

sql server 2008 示例数据库教程sql语句

ID:11323606

大小:26.54 KB

页数:8页

时间:2018-07-11

sql server 2008 示例数据库教程sql语句_第1页
sql server 2008 示例数据库教程sql语句_第2页
sql server 2008 示例数据库教程sql语句_第3页
sql server 2008 示例数据库教程sql语句_第4页
sql server 2008 示例数据库教程sql语句_第5页
资源描述:

《sql server 2008 示例数据库教程sql语句》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、--T-SQL字符串函数selectname,LEFT(name,12)asbiketype,SUBSTRING(name,9,4)asmodel,RIGHT(name,2)assize,RTRIM(style)asstylefromProduction.ProductwhereProductNumberlike'bk-t%';selectREPLACE(name,'mountain','Mtn')asReplaceName,STUFF(name,11,2,'x01')asStuffName,REVERSE(productnumber)a

2、sReverseNum,STUFF(productnumber,1,2,REPLICATE(0,3))asReplicateNum,productnumber+SPACE(4)+LOWER(productline)asProductLinefromProduction.ProductwhereProductID='771';selectname+CHAR(9)+str(makeflag)asProduct,ASCII(makeflag)asasciiMakeFlag,RTRIM(style)asstyle,UNICODE(rtrim(st

3、yle))asunicodeStylefromProduction.ProductwhereProductID='771';selectLEN(Description)asLenghthDescription,CHARINDEX('tech',description)asCharIndexDescription,PATINDEX('%bike%',description)asPatindexDescriptionfromProduction.ProductDescriptionwhereProductDescriptionID='321'

4、;select*fromProduction.ProductDescriptionwhereProductDescriptionID='321';declare@Name1varchar(30)set@Name1=(selectlastnamefromPerson.ContactwhereContactID='1829')declare@Name2varchar(30)set@Name2=(selectlastnamefromPerson.ContactwhereContactID='2580')select@Name1asName1,@

5、Name2asName2,Soundex(@Name1)assoundexname1,soundex(@Name2)assoundexname2,difference(@Name1,@Name2)assoundexdiff--T-SQL数学函数selectTerritoryID,AVG(SubTotal)asavgsales,SUM(subtotal)assumsales,MAX(subtotal)asmaxsales,MIN(subtotal)asminsalesfromSales.SalesOrderHeadergroupbyTerr

6、itoryIDorderbyTerritoryIDselectmin(name)asfirstproduct,MAX(name)aslastproductfromProduction.ProductselectCOUNT(*)asproductcount,COUNT(productmodelid)asmodelcount,COUNT(distinctProductModelID)asdistinctcountfromProduction.ProductselectColor,AVG(listprice)asavgprice,COUNT(*

7、)astotalAmount,GROUPING(color)asaggGroupfromProduction.ProductgroupbyColorwithrollupselectCHECKSUM_agg(CAST(Quantityasint))aschecksum_agg,CHECKSUM_agg(distinctCAST(quantityasint))aschecksumdistinctfromProduction.ProductInventoryselect*fromProduction.ProductInventorydeclar

8、e@agenlefloatset@agenle=3.1415926declare@sinefloatset@sine=SIN(@agenle)select@sineassine,degrees

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。