16_HAVING.pdf - CITS1402 Relational Database Management...

This preview shows page 1 - 6 out of 18 pages.

CITS1402Relational Database Management SystemsVideo 16 —HAVINGGordon RoyleDepartment of Mathematics & Statistics
QueryingThe basicSELECTstatement that we are using is:SELECT<column_names>FROM<table_references>WHERE<row_conditions>GROUP BY<group_columns>HAVING<group_conditions>ORDER BY<sorting_columns>LIMIT<number_rows>
GroupsRecall the “row-processing” that occurs when summary functionsare used.Starting with the table created byFROM,ITheGROUP BYclause divides the rows into groupsITheaggregateorsummaryfunctions are applied to each groupIThe output table has onesummary rowper groupBut what if you only want output forsome groups?
TheHAVINGstatementTheHAVINGstatement specifiesextra conditionsthat are appliedafterthe summary rows are formed andbeforethey are output.Only summary rows thatsatisfy the conditionsare outputNote: theWHEREconditions choose rowsbefore groupingand theHAVINGconditions choose (summary) rowsafter grouping.
Frequent winners

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture