Back to problems

Compare SQL counts, windows, and NULL semantics

SQL · ByteDance · Medium

Three tables are provided. users(id INT, country VARCHAR(2), created_at DATE) holds one row per registered user. orders(order_id INT, user_id INT, amount DECIMAL(10,2), created_at DATE) records purchases, and the amount column is allowed to be NULL. events(user_id INT, event_name VARCHAR(50), event_time TIMESTAMP) records user activity. A user may have no orders at all, no events at all, or many of each. Answer all four parts below and give the exact SQL each time. (a) Write…

Checking your access…