I have a table where i have two columns in the below fashion
sale_id status
268 5
268 1
268 1
268 1
283 5
283 5
283 5
284 5
284 1
284 1
284 1
284 1
284 1
284 1
As you can see, we have sale_id and status field. I need to write an SQL query where I find all sales_id where all rows have become 5.
So I would want to create a third column which mention in front of the sales_id that this sales_id is expired (if all rows became 5). For example, look at the below table. From the above table, I would want to create the below table
sale_id activity
268 active
283 expired
284 active
because sales_id 268 and 284 have some rows 5 but also some rows 1, therefore they are active. sales_id 283 have all rows 5, therefore, it should show expired in the activity.
Can someone please help how to comeup with this query