Sales Analysis – 3

Tables – product and sales are provided. Write SQL query to identify products which were sold only in first quarter of year 2019. If a product is sold in any other quarter then that is not supposed to be present in final output. Output should be product_id and product_name. Input Table: sales seller_id product_id buyer_id … Read more

Post Views – 1

Post views are being analysed using post_views table. This table contains information of all views on each posts date wise.Task is to find all authors who viewed at least one of their own posts. Sort the final output by their author_id in ascending order.   Input Table: post_views post_id author_id viewer_id view_date 22 2 4 … Read more

Product Sales Analysis – 2

Write an SQL query that reports the total quantity sold for every product id.   Input Table : sales sale_id product_id sale_year quantity price 20 80 2017 21 300 30 80 2018 23 400 40 13 2019 56 600   Output Table: product_id total_quantity 80 44 13 56   Explanation: product_id is Foreign Key and … Read more

Product Sales Analysis – 1

Write an SQL query that reports all product names of products in the “sales” table along with their selling year and price.   Input Table : sales sale_id product_id sale_year quantity price 20 80 2017 21 300 30 80 2018 23 400 40 13 2019 56 600   Input Table: product product_id product_name 80 Asus … Read more

Sales Analysis – 1

Tables – product and sales are provided. Being area manager, you are looking for best seller by total sales price to reward and motivate them for best results. If there is a tie, all sellers would be qualified for same reward. Write SQL query to fetch all seller_id by total sale price. Input Table: sales … Read more

Tutor taking atleast 3 classes for a student

Tutor data is provided tutor_students table below. Table contains data of a month with tutor_id and student_id along with date of month on which tutor took class.Write a SQL query that provides the pairs (tutor_id, student_id) where the tutor has taken at least 3 classes for a student in single month.   Input Table: tutor_students … Read more

Gamers Analysis – 1

Write an SQL query and identify first login date for each gamer.   Input Table: gamers_activity player_id device_id event_date games_played 7 22 2017-04-02 4 7 22 2017-06-05 3 9 33 2018-02-26 0 6 11 2017-05-07 7 6 44 2019-08-06 3   Output Table: player_id first_login 7 2017-04-02 9 2017-04-02 6 2017-04-02 Explanation: “gamers_activity” table shows the activity … Read more

Gamers Analysis – 2

Write a SQL query that identify the device that was first used to log in for each gamer.   Input Table: gamers_activity player_id device_id event_date games_played 7 22 2017-04-02 4 7 22 2017-06-05 3 9 33 2018-02-26 0 6 11 2017-05-07 7 6 44 2019-08-06 3   Output Table: player_id device_id 7 22 9 33 … Read more