levo

SQL, Big Data and Distributed Systems

Comparison operators, IN, AND, OR and sub-queries

  • 3 things to know
  • Component 2

Overview

Six comparison operators used in an SQL WHERE clause, difference between < and <= in a WHERE clause and term sub-query.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

List the six comparison operators used in an SQL WHERE clause.

Key term

A table Staff holds Salary. Write SQL to list all columns for staff earning more than 30000.

Key term

What is the difference between < and <= in a WHERE clause?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    List the six comparison operators used in an SQL WHERE clause.

    Model answer

    The six comparison operators are =, >, >=, <, <= and <>. The last of these tests for inequality.

  2. 2

    A table Staff holds Salary. Write SQL to list all columns for staff earning more than 30000.

    Model answer

    SELECT * FROM Staff WHERE Salary > 30000. The operator > excludes a salary of exactly 30000.

  3. 3

    What is the difference between < and <= in a WHERE clause?

    Model answer

    The operator < excludes the stated value. The operator <= returns rows equal to the stated value as well.

  4. 4

    Staff holds Department. Write SQL to list staff in either Sales or Finance using a single operator.

    Model answer

    SELECT * FROM Staff WHERE Department IN ('Sales', 'Finance'). The IN operator tests membership of a list of values.

  5. 5

    Explain why IN is often preferred to a chain of OR conditions.

    Model answer

    The IN operator states a list of acceptable values in one short clause. A long chain of OR tests is harder to read and harder to change.

  6. 6

    Staff holds Department and Salary. Write SQL to find staff in Sales earning over 25000.

    Model answer

    SELECT * FROM Staff WHERE Department = 'Sales' AND Salary > 25000. Each condition must be true for a row to be returned.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Data Structures: Arrays, Records and Hash Tables
Stacks, Queues, Linked Lists and Trees
Boolean Logic and Simplification
Algorithms, Pseudo-Code and Programming Constructs

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

KDW to HAT.
decryptsencryptscompresses

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AThe two are not the same.
BOpen source refers to the availability of the code.
CMuch open source software is free of charge.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

Backup means the copy of the data.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in SQL, Big Data and Distributed Systems, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.