/* App usage data are kept in the following table: TABLE sessions id INTEGER PRIMARY KEY, userId INTEGER NOT NULL, duration DECIMAL NOT NULL Write a query that selects userId and average session duration for each user who has more than one session. */ -- create a table CREATE TABLE students ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, userId INTEGER NOT NULL, duration DECIMAL NOT NULL ); -- insert some values INSERT INTO students VALUES (1, 'Ryan', 12, 25.3); INSERT INTO students VALUES (4, 'Ryan', 12, 25.3); INSERT INTO students VALUES (2, 'Joanna', 15, 52.3); INSERT INTO students VALUES (3, 'Joanna', 15, 22.3); -- fetch some values SELECT * FROM students ; select name, userid, avg(duration) as avg from students where userid in (select userid from students group by userid having count(*) > 1) group by userid
To embed this project on your website, copy the following code and paste it into your website's HTML: