logo

Back to questions

Consecutive Filing Years

Hard

Intuit offers several tax filing products, such as TurboTax and QuickBooks, which come in multiple versions.

Write a query to find the user ids of everyone who filed their taxes with any version of TurboTax three or more years in a row. Display the output in the ascending order of user ids.

Assumption:

  • As reflected in the table, a user can only file taxes once a year using one product.

Table:

Column NameType
filing_idinteger
user_idvarchar
filing_datedatetime
productvarchar

Example Input:

filing_iduser_idfiling_dateproduct
114/14/2019TurboTax Desktop 2019
214/15/2020TurboTax Deluxe
314/15/2021TurboTax Online
424/07/2020TurboTax Online
524/10/2021TurboTax Online
634/07/2020TurboTax Online
734/15/2021TurboTax Online
833/11/2022QuickBooks Desktop Pro
944/15/2022QuickBooks Online

Example Output:

user_id
1

Explanation

User 1 filed using TurboTax for consecutive 3 years. We do not include User 2 because they missed the filing in the third year and User 3 switched to QuickBooks in their third year.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.