Math examples
Examples of simple arithmetic, inline calculations, and a windowed total in queries.
Simple math
SELECT 42 + 1
FROM mylogs;
Inline calculation
SELECT (amount + 10) * upcharge AS total_amount
FROM payments
WHERE account_type = 'merchant';
Convert Fahrenheit to Celsius
SELECT (temp - 32) / 1.8 AS temp_celsius
FROM reactor_core_sensors;
Daily miles for each card
Calculate the daily miles for each card, at 1 mile for each 100 units spent:
SELECT
card,
SUM(amount) / 100 AS miles,
window_end AS ts
FROM TABLE(
TUMBLE(TABLE payments, DESCRIPTOR(eventTimestamp), INTERVAL '1' DAY))
GROUP BY card, window_start, window_end;
