Back to problems

Match requests and accepts into friendships in SQL

SQL · Roblox · Medium

You are given two append-only event tables that record friendship requests and acceptances. A friendship becomes real only when one user accepts a request the other user had already sent; the acceptance must not predate the request it answers. Produce a single PostgreSQL query that reports every distinct undirected friendship together with the date on which it first became valid. The tables are: friend_requests(req_id INT, requester_id INT, requestee_id INT, request_date…

Checking your access…