Which of the following factors would be affected in a patien…
Which of the following factors would be affected in a patient taking Coumadin?
Which of the following factors would be affected in a patien…
Questions
Which оf the fоllоwing fаctors would be аffected in а patient taking Coumadin?
Which оf the fоllоwing fаctors would be аffected in а patient taking Coumadin?
The fоllоwing SQL query creаtes а tаble named gym with the fоllowing columns and data: DROP TABLE IF EXISTS gym;CREATE TABLE gym (trans_id int PRIMARY KEY, userid text, workout_type text, calories_burned int, checkin timestamp, duration int);INSERT INTO gym VALUES(1,'user_1063','CrossFit',429,'2023-06-01 07:06:00',38),(2,'user_1104','Swimming',954,'2023-06-01 10:54:00',67),(3,'user_1014','CrossFit',1464,'2023-06-02 08:52:00',140),(4,'user_1010','CrossFit',1325,'2023-06-02 11:50:00',61),(5,'user_1010','Weightlifting',344,'2023-06-03 06:24:00',127),(6,'user_1098','Yoga',344,'2023-06-03 12:06:00',48),(7,'user_1071','Swimming',1102,'2023-06-03 14:29:00',112),(8,'user_1034','Yoga',849,'2023-06-03 17:14:00',133),(9,'user_1023','CrossFit',723,'2023-06-04 09:02:00',139),(10,'user_1063','Cardio',1028,'2023-06-04 16:27:00',122),(11,'user_1034','Pilates',698,'2023-06-04 19:15:00',128),(12,'user_1010','Yoga',672,'2023-06-05 08:58:00',168),(13,'user_1006','Weightlifting',291,'2023-06-05 09:13:00',122),(14,'user_1023','Weightlifting',1682,'2023-06-05 11:00:00',170),(15,'user_1028','Weightlifting',432,'2023-06-05 20:20:00',177),(16,'user_1071','CrossFit',948,'2023-06-06 06:48:00',55),(17,'user_1104','Yoga',805,'2023-06-06 15:09:00',158),(18,'user_1006','Yoga',998,'2023-06-07 08:12:00',151),(19,'user_1010','Swimming',502,'2023-06-07 08:56:00',171),(20,'user_1063','Cardio',1058,'2023-06-07 09:28:00',65),(21,'user_1097','Yoga',1169,'2023-06-07 14:26:00',84),(22,'user_1071','Weightlifting',1012,'2023-06-08 06:02:00',157),(23,'user_1104','Yoga',1602,'2023-06-08 16:29:00',155),(24,'user_1071','Weightlifting',1194,'2023-06-09 07:07:00',159),(25,'user_1023','Yoga',322,'2023-06-11 09:48:00',113),(26,'user_1063','CrossFit',1387,'2023-06-11 13:03:00',179),(27,'user_1063','CrossFit',637,'2023-06-14 13:45:00',146) ; Source: https://www.kaggle.com/datasets/mexwell/gym-check-ins-and-user-metadata Here are brief descriptions of the data fields: trans_id: unique identifier for the visit userid: ID of the user who checked in workout_type: Type of workout performed during the visit calories_burned: Estimated number of calories burned during the workout checkin: date and time user checked in duration: time from check in to completion of workout (minutes) Run the code above using pgAdmin to create this table and test the SQL query you will create below. Write a SQL query that performs the following tasks in three parts using a common table expression (CTE): Part 1: Each user can only check in once per day, so create a new field that contains the date portion of the checkin field and call it checkin_date. Aggregate the data at the workout_type + checkin_date level, and calculate the daily calories burned per minute for each workout_type on each date by dividing the sum of calories_burned by the sum of duration (call it cal_per_min). The query should return three columns: workout_type, checkin_date, and cal_per_min. For example, the calories burned per minute is about 8.43 for Cardio on 6/4/2023 and about 11.29 for CrossFit on 6/1/2023. Rounding is not necessary. Part 2: Calculate a 3-day moving average of the daily calories burned per minute for each workout_type on each day calculated in Part 1. The moving average window should include the three preceding check-in dates but exclude the current check-in date for which you’re calculating the average and any subsequent ones (call it cal_per_min_3dma). Count the number of rows within each window frame and store this count as well. Part 3: Return checkin_date, workout_type, cal_per_min, and cal_per_min_3dma. Show only the check-in dates that have a sufficient number of days available to calculate the 3-day moving average. The resulting table should look like exactly like this (aside from rounding): checkin_date workout_type cal_per_min cal_per_min_3dma 6/6/23 CrossFit 17.24 10.12 6/11/23 CrossFit 7.75 12.1 6/14/23 CrossFit 4.36 10.06 6/9/23 Weightlifting 7.51 4.76 6/7/23 Yoga 9.22 5.23 6/8/23 Yoga 10.34 6.11 6/11/23 Yoga 2.85 8.22 Here is a template to follow for constructing the query:-- Use common table expression to write the query in three partsWITH daily_workout AS ( --Part 1 ),moving_average AS ( --Part 2) -- Part 3SELECT Submit your complete query in the window below.