Question: There are 3 queries I need to learn how to write in SQL Needed information that tables design, column names, data types, relations between tables

There are 3 queries I need to learn how to write in SQL


Needed information that tables design, column names, data types, relations between tables are described in photo below.sessions id varchar id_user varchar ts_start timestamp ts_end timestamp users id varchar

1-)For each user, find the percentage of users that have fewer posts than them. Sort the results from high percentage to low, and limit the output to the 30 users with the highest post count.
2-)For each user, find the percentage of users that have spent less time on the site than them. Omit users whose first month was the last month in the data. Sort the results from high percentage to low, and limit the output to the 30 users with the highest post count.
3-)For each user, find the percentile they're in for time on site. We'll define percentile as the percentage of users who spent as much or less time on the site than the given user.


sessions id varchar id_user varchar ts_start timestamp ts_end timestamp users id varchar email varchar posts age int id varchar gender varchar id user varchar id session varchar ts timestamp type varchar

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 To find the percentage of users with fewer posts than them we need the following Count of posts for each user userpostcount Other users with fewer post counts than each userwe have to calculate this ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!