SQL Server 2012 SQL, Transact SQL - Jérôme GabillaudDescripción completa
Full description
The form: 1. Select (field) 2. From (table) 3. Where row level condition 4. Grou b! (field) ". #avin$ (count) $rou level condition %. &rder b! (field) a'c or de'c &ther one' 1. reate reate tabl table e 2. reate reate iew iew 3. reate reate or relace relace view * udate 4. +ro view * delete delete ". ,n'e ,n'ert rt %. -da -date te . +ele +elete te /ore ba'ic arameter' 1. Select 0 : 0 : Select' all field' 2. 0 all field' 3. Where Where 'ometh 'omethin$ in$ + +:: dd' another condition 4. Where Where 'ometh 'omethin$ in$ & &:: dd' another condition ". Select Select (field) (field) S S name name :ename' the field %. Selec Selectt oncat($iven5 6 65 middle5 6 65 'urname) : 'urname) : combine' field' into one5 u'uall! for name' . Where Where fiel field d ,S ,S null null : whenever !ou are loo7in$ for a null function5 !ou mu't u'e ,S 8. 9value9 9value9 : : The uer! will add an!thin$ before or after the ercenta$e ;. Where Where 'uburb 'uburb li7e 69we't9< : 69we't9< : =ou mu't u'e li7e in the where clau'e when !ou are u'in$ 69<
1>. Select +i'tinct +i'tinct field: field: ,n a table5 a column ma! contain man! dulicate value'? and 'ometime' !ou onl! want to li't the different (di'tinct) value'. 11. Select truncate truncate(calc (calc or field5 how man! decimal'): reduce' the decimal lace' in the field 12. Select count(0) count(0):: count' the row' in the table 13. Grou @! (field): (field): $rou' u the field 'elected 14. Select Tower,+5 ount(0) From connect Grou b! Tower,+ ount' how man! time' each individual Tower,+ 'how' u 1". Select min(field) min(field) or or maA(field) maA(field):: 'how' the maA or min of that articular field 1%. Select av$(field) av$(field):: avera$e of the field 1. Select datediff(date5field) datediff(date5field):: find' the date difference in da!' 18. S!'date():: S!'tem date that can be u'ed S!'date() in function' li7e datediff('!'date()5dob) 1;. +atediff('!'date()5+&@)B3%".2":: to find +atediff('!'date()5+&@)B3%".2" a$e 2>. Select da!ofwee7(date) da!ofwee7(date):: number value5 'unda!:1 21. Select da!name(date) da!name(date)Sunda!: Sunda!: Word 22. Where !ear(date) !ear(date) or or da!(date) da!(date) or or month(date) month(date) value : condition for the reue'ted value
23. From call' C&, C&, mobile mobile & & call'.mobile,+ call'.mobile,+ mobile.mobile,+: Coin' two table' to$ether 24. Where 'omethin$ + ('omethin$<'omethin$< & 'omethin$<'omethin$<) 2". SDE oin' oin' are are u'ed to combine row' from two or more table' ba'ed on the common field between them. /o't common t!e i' the SDE , C&,('imle oin) 2%. E T# C&,S 2. -,&:: ombine' two uerie' to$ether5 -,& to$ether5 mu't have 'imilar field'. $ one table ha' name and count5 the other mu't have name and a number field5 ma!be >. 28. Where 'omethin$ &T , ('elect , ('elect 0 from call'): -'ed to find 'omethin$ thatH' not in the field