with recursive cte as (select product,quantity,1 as level from products2 union all select cte.product,cte.quantity -1,level+1 from cte join products2 as p on p.product=cte.product where cte.quantity>1) select * from cte this can be done also
everytime i watch your videos I learn a new approach to solve. But my question is how many questions you neeed to solve before you attend for a data analyst/ data engineer role having 1.5 years. I mean there can be n number of sql questions. so what be the generic approach. I will wait for your reply.
Generic approach will be to learn the basics well. You can develop your logical skills slowly with experience. If you want to become a data analyst or engineer sql alone will not help you. You should learn data warehouse management as e
Its all about the order of execution, first the where clause will be considered, then the select clause. If we include1 as well, then Quantity-1 will make it 0, which is not required.