Senthilkumar Posted September 13, 2023 Share Posted September 13, 2023 Deat Team, I want to sum the column values of last updated month from database. My query is select Category, sum(Total) as SUM from equipement_population_data where Dealer_ID = '$Emp_No' AND Month = ________ group by Category order by SUM DESC Example: If the month is found 2023-08, (that is previous month) then the query should complete like Month = '2023-08' . If last updated month is found 2023-07 then, then the query should complete like Month = '2023-07'. If last updated month is found 2023-06 then, then the query should complete like Month = '2023-06'. If last updated month is found 2023-01 then, then the query should complete like Month = '2023-01' My database table looks Can any one help me how to do this Quote Link to comment Share on other sites More sharing options...
Barand Posted September 13, 2023 Share Posted September 13, 2023 ... AND Month = (SELECT max(Month) FROM equipment_population) Quote Link to comment Share on other sites More sharing options...
Senthilkumar Posted September 13, 2023 Author Share Posted September 13, 2023 Dear Barand, Thanks for your immediate response. I changed the code as per your suggession. Noe it is working properly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.