분류 전체보기(9)
-
SQL - Active Businesses : Selecting 'xx' greater than AVG
Active Businesses Medium Table: Events Write an SQL query to find all active businesses. An active business is a business that has more than one event type with occurences greater than the average occurences of that event type among all businesses. The query result format is in the following example: ANALYSIS: Here the question defines an active user as COUNT(DISTINCT event_type) > 1 and occurre..
2020.04.09 -
SQL- Human Traffic of Stadium: general N consecutive days query
Human Traffic of Stadium Hard X city built a new stadium, each day many people visit it and the stats are saved as these columns: id, visit_date, people Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive). For example, the table stadium: Note: Each day only have one row record, and the dates are increasing with id in..
2020.04.09 -
SQL - Find Cumulative Salary of an Employee
Find Cumulative Salary of an Employee Hard The Employee table holds the salary information in a year. Write a SQL to get the cumulative sum of an employee's salary over a period of 3 months but exclude the most recent month. The result should be displayed by 'Id' ascending, and then by 'Month' descending. Example Explanation Employee '1' has 3 salary records for the following 3 months except the..
2020.04.07 -
SQL - User Activity for the Past 30 Days II
There is no primary key for this table, it may have duplicate rows. The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message'). The table shows the user activities for a social media website. Note that each session belongs to exactly one user. Write an SQL query to find the average number of sessions per user for a period of 30 days ending 2019-07-..
2020.04.07 -
SQL - Department Highest Salary
Department Highest Salary Medium The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. The Department table holds all departments of the company. Write a SQL query to find employees who have the highest salary in each of the departments. For the above tables, your SQL query should return the following rows (order of rows doe..
2020.04.07 -
SQL - Reported Posts II
Reported Posts II Table: Actions Column Name Type user_id int post_id int action_date date action enum extra varchar There is no primary key for this table, it may have duplicate rows. The action column is an ENUM type of ('view', 'like', 'reaction', 'comment', 'report', 'share'). The extra column has optional information about the action such as a reason for report or a type of reaction. Table:..
2020.04.07