Tuesday, January 8, 2019

Sample SQL using the BETWEEN Operator

The BETWEEN operator selects a range of data between two values. The values can be numbers, characters, or dates.

Characters:
SELECT * FROM Administrator.CUSTOMERS
WHERE COMPANYNAME BETWEEN 'ACME' AND 'CHARLIE CHAN'

Date:
SELECT * FROM Administrator.TRANSACTIONS
WHERE CREATE_DATE BETWEEN TO_DATE('12/01/2012', 'MM/DD/YYYY') AND TO_DATE('12/31/2012', 'MM/DD/YYYY')

Number:
SELECT * FROM Administrator.ITEMS
WHERE COST_0 BETWEEN 100 AND 200

No comments:

Post a Comment