Jump to content

Sum column value of last updated month


Senthilkumar

Recommended Posts

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 

image.thumb.png.c529f8e671fa591265ff97367c642b77.png

Can any one help me how to do this

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.