A brief note on COUNT, SUM, AND and OR: counting and adding records, joining two conditions, ranges, and a method for reading, completing and correcting SQL scripts, with practice, a program and questions to check yourself.
A brief note on COUNT, SUM, AND and OR. Read it before a test. Try each question at the end before you open its answer.
COUNT(*): the number of records that pass. One number.SUM(Field): the total of a numeric field over the records that pass. One number.AND: both parts true. Usually fewer records.OR: at least one part true. Each record is output once.Field >= low AND Field <= high.Field < low OR Field > high.Day = 'Mon' OR Day = 'Tue'.FROM: the table.WHERE: keep the records that pass.COUNT or SUM: one number, if present.ORDER BY: sort.SELECT: write only the chosen fields.SELECT, FROM, WHERE, ORDER BY.ASC or DESC after the field.The program counts and adds with two conditions, first joined with AND and then with OR.
Log in to join the discussion.
Loading…