forked from baldimario/cq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_between.sql
More file actions
27 lines (23 loc) · 765 Bytes
/
example_between.sql
File metadata and controls
27 lines (23 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- Example: Using BETWEEN operator with SQL comments
-- This demonstrates the BETWEEN operator for range queries
/*
* BETWEEN is inclusive on both ends
* Syntax: column BETWEEN lower_value AND upper_value
* Equivalent to: column >= lower_value AND column <= upper_value
*/
-- Select users within age range 25-35
SELECT
name,
age,
role
FROM './data/users.csv'
WHERE age BETWEEN 25 AND 35 -- Age range filter
ORDER BY age DESC;
-- You can also use BETWEEN with strings (alphabetical order)
-- SELECT name FROM './data/users.csv'
-- WHERE name BETWEEN 'Alice' AND 'John'
-- ORDER BY name;
-- BETWEEN works with arithmetic expressions too
-- SELECT name, age, age * 2 AS double_age
-- FROM './data/users.csv'
-- WHERE age * 2 BETWEEN 50 AND 70;