SQL Interview Questions – Leetflex Banned Accounts

Spread the love

Problem Description –

Write an SQL query to find the account_id of the accounts that should be banned from Leetflex. An account should be banned if it was logged in at some moment from two different IP addresses.

Return the result table in any order.

The query result format is in the following example.

Problem Link – Leetflex

Difficulty Level – Medium

Solution –

FROM LogInfo as t1, LogInfo as t2
WHERE t1.login BETWEEN t2.login AND t2.logout
AND t1.account_id = t2.account_id
AND t1.ip_address != t2.ip_address

Rating: 1 out of 5.

Leave a Reply