#!/usr/bin/env bash if [ "$#" -ne 1 ]; then echo "Usage: query.sh " exit 1 fi TIME=$1 shift DB="db/rowing.sqlite3" cat< (SELECT REPLACE(MAX(max_time), ':', '') FROM rowing)) THEN 'You are off the charts too slow' ELSE '${TIME} is ' || CASE WHEN SUBSTR(LOWER(word), 1, 1) IN ('a', 'e', 'i', 'o', 'u') THEN 'an' ELSE 'a' END || ' ' || word || ' time' END AS message FROM ( SELECT rating AS word FROM rowing WHERE '${TIME}' BETWEEN min_time AND max_time UNION ALL SELECT 1 AS word LIMIT 1 -- dummy selection to make sure the out-of-bounds messages get shown ); EOF