Professional Documents
Culture Documents
FUNCTIONS
Built B iltIn I SQLhasmanybuiltinfunctionsforperformingcalculationsondata. Cannotbemodified UserDefined Createdandmodifiedbyusers RowsetFunctions Usedtoreferencetables A Aggregate t F Functions ti Operateonacollectionofvaluesbutreturnsasinglevalue ScalarFunctions Operateonasinglevalueandreturnasinglevalue
AggregateFunctions
SQLAggregateFunctions
SQLaggregatefunctionsreturnasinglevalue,calculatedfromvaluesinacolumn TypicallyignoresNULLvalues
Usefulaggregatefunctions: AVG() Returnstheaveragevalue COUNT() Returnsthenumberofrows FIRST() Returnsthefirstvalue LAST() Returnsthelastvalue MAX() Returnsthelargestvalue MIN() Returnsthesmallestvalue SUM() Returnsthesum
10
ScalarFunctions
ScalarFunctions Operateonasinglevalueandreturnasinglevalue
Usefulscalarfunctions: UCASE() Convertsafieldtouppercase LCASE() Convertsafieldtolowercase MID() Extractcharactersfromatextfield LEN() Returnsthelengthofatextfield ROUND() Roundsanumericfieldtothenumberofdecimals specified NOW() Returnsthecurrentsystemdateandtime FORMAT() Formatshow h afield fi ldis i to t be b displayed di l d
11
ComparisonOperators
=(Equals) >(GreaterThan) <(LessThan) >=(GreaterThanorEqualTo) < (L <= (LessTh ThanorEqual E lTo) T ) <>(NotEqualTo) ! (Not != (N E Equal lT To) ) !<(NotLessThan) !>(NotGreaterThan)
12
ArithmeticOperators
+(Add) (Subtract) *(Multiply) /(Divide) ( ) %(Modulo)
13
LogicalOperators
ALL AND ANY BETWEEN EXISTS IN LIKE NOT OR SOME
14
ColumnAliasing
SELECTproductName ASproduct,unitPrice AS priceFROMproductsWHEREunitPrice >50 Changesthe productName columnto product
15
Wildcards
Wildcard % _ [charlist] Description Asubstituteforzeroormorecharacters Asubstituteforexactlyonecharacter Anysinglecharacterincharlist
16
THATS AN INTRODUCTION TO . . .
17