课件课后练习代码经典案例_第1页
课件课后练习代码经典案例_第2页
课件课后练习代码经典案例_第3页
课件课后练习代码经典案例_第4页
课件课后练习代码经典案例_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

selectselectmin(create_date)fromselectselectunix_host,os_username,create_datefromwherecreate_date=将inda直接换为上述查询语句,这样的查询形式称为非关联子查询。语句的执行顺序是先执行子查询(只执行一遍,若子查询的返回结果为多条,系统会自动去重)selectunix_host,os_username,create_datefromwherecreate_date=(selectmin(create_date)from图-selectcreate_datefromwhereos_username='huangr';andunix_host='192.168.0.26'selectunix_host,create_date,os_usernamefromwherecreate_date(selectcreate_datefromwhereos_username='huangr'andunix_host='192.168.0.26');图-图-selectselectcreate_datefromwhereos_username=selectunix_host,create_date,os_usernamefromwhere(selectcreate_datefromservicewhereos_username='huangr');selectunix_host,create_date,os_usernamefromwhere(selectmax(create_date)fromservicewhereos_username='huangr');selectunix_host,create_date,os_usernamefromwhere(selectcreate_datefromservicewhereos_username='huangr');selectunix_host,create_date,os_usernamefromwhere(selectmin(create_date)fromservicewhereos_username='huangr');图-mender_idfrommender_idfromselectreal_namefromwhereidinmender_idfrom图-mender_idfrommender_idfrom将上述查询的结果作为hee条件的值,即查询哪些人的帐务帐号ID没有落在上述查询的结果集中,也就是哪些人的帐务帐号ID跟结果集中的所有值都不相等。当子查询的返回结果中包含有null值,对于ntin(all)来说,l语句不会返回任何结果。因为任何跟null比较,结果都不是u。selectreal_namefromwherenotmender_idfromaccountmender_idisnotnull);显示unix服务器ip地址,开通日期,os帐号名,结果集中只包含每台unix服务器上最早开通的os图-selectunix_host,min(create_date)fromgroupbyselectunix_host,os_username,create_datefromwhere(unix_host,create_date)(selectunix_host,min(create_date)fromservicegroupbyunix_host);图-selectto_char(min(create_date)+9,'yyyymmdd')fromservicegroupbyselectunix_host,os_username,create_datefromwhere(unix_host,to_char(create_date,'yyyymmdd'))in(selectunix_host,to_char(min(create_date)+fromgroupby图-selectselectround(sysdate-create_date)selectavg(round(sysdate-create_date))fromservicewherei.unix_host=selectunix_hostos_usernameround(sysdate-create_date)open_agefromserviceowhereround(sysdate-create_date)(selectavg(round(sysdate-fromservicewhereo.unix_host=图-select1fromservicewhereo.idselectreal_namefromaccountwhereexistsselect1fromaccountwhereo.id图-selectaccount_idselectaccount_idfromselectselect1fromservicewhereo.id=selectreal_namefromwhereidin(selectaccount_idfromselectreal_namefromaccountwhere(select1fromserviceiwhereo.id=i.account_id);图-该问题可以用关联子查询的notexists对于主表中的记录来说不存在(notexists)如下情况:他的帐务帐号ID是某select1select1fromservicewhereo.id该查询执行后返回norowsselected。注意notexists关心是否有返回结果而不是返回结果具selectreal_namefromaccountwherenot(select1fromaccount图-selectaccount_idselectaccount_idfromselectselect1fromservicewhereo.id=若没有,主查询中的notexists是成立的,即该客户没有申请登录业务selectreal_namefromwhereidnotin(selectaccount_idfromselectreal_namefromaccountwherenotexists(select1fromserviceiwhereo.id=图-fromaccountfromaccountajoinserviceona.id=columnreal_nameformatcolumnos_usernameformata12columnunix_hostformata16fromaccountajoinserviceona.id=图-fromfromaccountajoins

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论