From a0637960b3f0ce41fd0777a396dc92f099b4a57b Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Wed, 29 Jun 2022 04:19:22 -0300 Subject: [PATCH] add src/sql/queries/word-count-by-verse.sql --- src/sql/queries/word-count-by-verse.sql | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/sql/queries/word-count-by-verse.sql diff --git a/src/sql/queries/word-count-by-verse.sql b/src/sql/queries/word-count-by-verse.sql new file mode 100644 index 0000000..8afb937 --- /dev/null +++ b/src/sql/queries/word-count-by-verse.sql @@ -0,0 +1,24 @@ + +-- | DESCRIPTION +-- +-- This query counts the number of verses where a +-- given word (or phrase) appears. +-- +-- | EXAMPLE RESULT SET +-- +-- word verses +-- ----- ------- +-- Allah 2001 + +SELECT + "Allah" AS word, + COUNT(verses.id) AS verses +FROM + verses + INNER JOIN qurans ON qurans.id = verses.quran_id + INNER JOIN chapters ON chapters.id = verses.chapter_id +WHERE + qurans.locale = "en" + AND verses.content LIKE '%' || word || '%' +LIMIT + 1;