Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Window Functions/Chapter4/video2_bool_approch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Hi Ami,

-- I find a way to solve the same problem with bool operation approach. Please check it, if anything wrong
-- plz correct it and merge it.
-- A.BoBo

select query.* from
(
SELECT species,
name,
checkup_time,
heart_rate,
AVG(heart_rate) OVER (PARTITION BY species)::decimal(5,2),
(heart_rate > AVG(heart_rate) OVER (PARTITION BY species))::bool as flag
FROM routine_checkups
ORDER BY species ASC,
checkup_time ASC
) query
where query.flag is true