ocp051題庫筆記講解1z0v902解析_第1頁
ocp051題庫筆記講解1z0v902解析_第2頁
ocp051題庫筆記講解1z0v902解析_第3頁
ocp051題庫筆記講解1z0v902解析_第4頁
ocp051題庫筆記講解1z0v902解析_第5頁
已閱讀5頁,還剩6頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1Z0-051V9.022017-6-5ExaminethedataintheORD_ITEMS Youwanttofindoutifthereisanyiteminthetableforwhichtheaverageumtyismorethan50.YouissuethefollowingSQL>SELECTFROMord_itemsGROUPBYitem_noHAVINGWhichstatementistrueregarding eofthisItexecutessuccessfullyandgivesthecorrectItgivesanerrorbecausetheHAVINGclauseisnotItexecutessuccessfullybutdoesnotgivethecorrectItgivesanerrorbecausetheGROUPBYexpressionisnotD.GROUPBY表達式無效。HAVING2個組函數(shù),且嵌套內(nèi)的值已經(jīng)是最大值了,且只有一個,再createtablet116(ORD_NOnumber,ITEM_NOnumber,QTYnumber);insertintot116values(1,111,10);insertintot116valuesinsertintot116values(1,333,30);insertintot116values(2,333,30);insertintot116values(2,444,40);insertintot116valuesselect*fromSELECTFROMGROUPBYHAVINGSELECTFROMGROUPBYHAVINGSELECTFROMGROUPBYSELECTFROMGROUPBYSELECT(20+30+40+40)/4FROMSELECTFROMGROUPBYSELECTFROMGROUPBYHAVINGMAX(qty)selectavg(mq)from(SELECTMAX(qtyFROMGROUPBY)SELECTSELECTFROMGROUPBYHAVINGMAX(qty)selectavg(mq)from(SELECTMAX(qty)mqFROMGROUPBYHAVINGMAX(qty))WhichstatementsaretrueregardingtheWHEREandHAVINGclausesinaSELECTstatement?(Chooseallthatapply.)TheHAVINGclausecanbeusedwithaggregatefunctionsinTheWHEREclausecanbeusedtoexcluderowsafterdividingthemintogroups.TheWHEREclausecanbeusedtoexcluderowsbeforedividingthemintogroups.TheaggregatefunctionsandcolumnsusedintheHAVINGclausemustbespecifiedintheSELECTlistofthequery.TheWHEREandHAVINGclausescanbeusedinthesamestatementonlyiftheyareappliedtodifferentcolumnsinthetable.A.HAVING子句能在子查詢中使用聚合函數(shù)。createtablet117(IDnumber,QTYnumber);insertintot117values(1,10);insertintot117valuesinsertintot117values(1,30);insertintot117values(2,30);insertintot117values(2,40);insertintot117valuesSELECTid,FROMGROUPBYIDHAVINGAVG(qty)>20;SELECT*FROMSELECTID,AVG(qty)FROMGROUPBYSELECT*FROMT117WHEREQTY>10SELECTID,AVG(qty)FROMt117WHEREQTY>10GROUPBYIDSELECTID,AVG(qty)FROMWHEREQTY>10GROUPBYID--;HAVINGAVG(qty)>30SELECTID,AVG(qty)FROMWHEREQTY>10GROUPBYIDHAVINGSELECTAVG(qty)FROMWHEREQTY>10GROUPBYIDHAVINGSELECTID,max(qty)FROMWHEREQTY>10GROUPBYIDHAVINGHAVINGSELECTID,AVG(qty)FROMWHEREQTY>10GROUPBYIDHAVINGViewtheExhibitandexaminethestructureofthePROMOTIONSExaminethefollowingtwoSQLStatementSQL>SELECTpromo_category,SUM(promo_cost)FROMpromotionsWHEREpromo_end_date-promo_begin_date>30GROUPBYpromo_category;StatementSQL>SELECTpromo_category,sum(promo_cost)FROMpromotionsGROUPBYHAVINGMIN(promo_end_date-WhichstatementistrueregardingtheabovetwoSQLstatement1givesanerror,statement2executesstatement2givesanerror,statement1executesstatement1andstatement2executesuccessfullyandgivethesameoutputstatement1andstatement2executesuccessfullyandgiveadifferentoutput評估下面的2個語句21執(zhí)行成功。SELECTpromo_category,SUM(promo_cost)FROMpromotionsWHEREpromo_end_date-promo_begin_date>30GROUPBYpromo_category;SELECTpromo_category,sum(promo_cost)FROMpromotionsGROUPBYHAVINGMIN(promo_end_date-ExaminethedataintheORD_ITEMSORD_NOITEM_NO111223EvaluatethefollowingSQL>SELECTitem_no,FROMHAVINGAVG(qty)>MIN(qty)*GROUPBYWhichstatementistrueregarding eoftheaboveItgivesanerrorbecausetheHAVINGclauseshouldbespecifiedaftertheGROUPBYclause.ItgivesanerrorbecausealltheaggregatefunctionsusedintheHAVINGclausemustbespecifiedintheSELECTlist.Itdisystheitemnoswiththeiraveragetywheretheaveragetyismorethandoubletheminimumtyofthatiteminthetable.Itdisystheitemnoswiththeiraveragetywhereaveragetyismorethandoubletheoverallminimumtyofalltheitemsinthetable.HAVINGGROUPBYA選項不正確,HAVINGGROUPBYSELECTitem_no,FROMHAVINGAVG(qty)>MIN(qty)*GROUPBYSELECTitem_no,AVG(qty),MIN(qty),MIN(qty)*2FROMT116GROUPBYHAVINGAVG(qty)>MIN(qty)*ViewtheExhibits andexaminethestructuresofthePRODUCTS,SALES,andCUSTOMERStables.Yd_id,prod_name,prod_list_price,ty_sold,cust_last_nameFROMproductspNATURALJOINsalessNATURALJOINcustomersWHEREprod_idWhichstatementistrueregarding eofthisItexecutesItproducesanerrorbecausetheNATURALjoincanbeusedonlywithtwotables.ItproducesanerrorbecauseacolumnusedintheNATURALjoincannothaveaqualifier.ItproducesanerrorbecauseallcolumnsusedintheNATURALjoinshouldhaveaqualifier.PRODUCTS,SALES,andCUSTOMERSSELECTd_id,prod_name,prod_list_price, FROMproductspNATURALJOINsalessNATURALJOINcustomerscWHEREprod_id=148;--SELECTprod_id,prod_name,prod_list_price, FROMproductsNATURALJOINsalessNATURALJOINcustomerscWHEREprod_id=148;SELECTprod_id,cust_id,d_name, ty_sold,FROMproductsNATURALJOINsalessNATURALJOINcustomerscWHEREprod_id=148;NATURAL FROMtablelNATURALJOINDROPTABLEt120X;DROPTABLEt120Y;DROPTABLEcreatetablet120X(anumber,bnumber,cnumber);createtablet120Y(bnumber,cnumber,dnumber);createtablet120Z(dnumber,enumber,fINSERTINTOT120XVALUESINSERTINTOT120YVALUES(2,3,4);INSERTINTOT120YVALUES(2,3,40);INSERTINTOT120YVALUESINSERTINTOT120ZVALUES(4,5,6);INSERTINTOT120ZVAL

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論