I have one small doubt in this question where current year for rahul and sanjay are 2012 only know but in the output it has been mentioned as 2011. can you please clear this doubt??
Hi @sabesanj5509
In the output, the year is the value where the marks in that year is greater than or equal to the marks in the previous year. So, in this case for Rahul, marks in 2011 is greater than or equal to marks in 2010. So, in the output 2011 is shown. Similarly for Sanjay, marks in 2011 is greater than or equal to marks in 2010, so 2011 is displayed.
Let me know if you have any more questions.
Please like, share and subscribe to my channel
Thanks
@@datasculptor2895 Thanks for the detailed explanation man. I have subscribed the channel and will like and surely share your videos on going forward.
MYSQL Solution
Select Name,Marks,Years,Pre_Year from
(Select *, Case When Marks>=Pre_Year then 1 else 0 end as Flag from
(Select *,Lag(Marks) over (Partition by Name Order by Years) as Pre_Year from Marks)N)N
Where Flag=1;
Nice. Please subscribe to my channel