sql_server2000知识点全集1

sql_server2000知识点全集1

ID:6878154

大小:216.50 KB

页数:84页

时间:2018-01-29

sql_server2000知识点全集1_第1页
sql_server2000知识点全集1_第2页
sql_server2000知识点全集1_第3页
sql_server2000知识点全集1_第4页
sql_server2000知识点全集1_第5页
资源描述:

《sql_server2000知识点全集1》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、mysql查询语句全集--列出pet所有的列select*frompet--列出指定的列selectname,ownerformpet--直接进行算术运算,对字段起别名selectsin(1+2)assin--where条件select*frompetwhere(birth>'1980'andspecies='dog')orspecies='bird'--对null的条件select*frompetwheresexisnotnull--所有名字第四位是n的宠物信息是select*frompetwhereown

2、erlike'___n%'--所有主人名叫gwen或benny的宠物select*frompetwhereownerin('gwen','benny')--查询出生日期在90年代是宠物,相当与>=and<=select*frompetwherebirthbetween'1990'and'1999'--按主人姓名排序,相同的按宠物姓名倒序排列select*frompetorderbyowner,namedesc--查询性别为公的宠物,按生日倒序排列select*frompetwheresex='m'orderb

3、ybirthdesc--char_lenngth()返回的字符的长度,length()返回字节长度SELECTowner,length(owner),char_length(owner)FROMpetp;--列出养有宠物狗的人名selectdistinctownerfrompetwherespecies='dog'--用两种方法查询出所有狗和猫的名字、出生年份、出生月份selectname,left(birth,4)asyear,mid(birth,6,2)asmonthfrompetwherespecies

4、='dog'orspecies='cat'selectname,year(birth)asyear,month(birth)asmonthfrompetwherespeciesin('dog','cat')--查询所有名字中存在字母'e'的人,将他们养的宠物按类别、年龄排序selectname,species,birthfrompetwhereownerlike'%e%'orderbyspecies,birthdesc--数字函数selectround(2.345,2),truncate(2.345,2),m

5、od(323,5)--日期函数selectnow(),curdate(),curtime()selectadddate('2007-02-02',interval31day)--求出所有宠物的年龄selectname,birth,truncate(datediff(now(),birth)/365,0)asage1,year(now())-year(birth)-(dayofyear(birth)>dayofyear(now()))asage2frompet--分组函数selectmin(birth),max

6、(birth),avg(birth),count(*),count(sex),sum(birth)frompet--每种宠物各有几只selectspecies,count(*)frompetgroupbyspecies--查询年龄最大的宠物的信息select*frompetwherebirth=(selectmax(birth)frompet)--每年各出生了几只宠物selectyear(birth),count(*)frompetgroupbyyear(birth)--鸟和猫的性别比例selectspeci

7、es,sex,count(*)frompetwherespeciesin('cat','bird')groupbyspecies,sex--各种宠物年龄的和selectspecies,sum(truncate(datediff(now(),birth)/365,0))asSumAgefrompetgroupbyspecies--数量大于1的宠物种类selectspecies,count(*)ascfrompetgroupbyspecieshavingc>=2--基本双表关联selecta.name,a.spe

8、cies,a.sex,b.date,b.type,b.remarkfrompeta,eventbwherea.name=b.name--查询宠物产仔时的年龄selecta.name,a.species,truncate(datediff(b.date,a.birth)/365,0)asagefrompeta,eventbwherea.name=b.nameandb.type='litter'--90

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

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

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