SQL to calculate number of values for each day based on a max value from previous date
SQL to calculate the number of values for each day based on a max value from the previous date
I completed my post-graduation in 2013 in the engineering field. Engineering is the application of science and math to solve problems. Engineers figure out how things work and find practical uses for scientific discoveries. Scientists and inventors often get the credit for innovations that advance the human condition, but it is engineers who are instrumental in making those innovations available to the world. I love pet animals such as dogs, cats, etc.
Aryan Kumar
31-Jul-2023Sure, here is the SQL to calculate the number of values for each day based on a max value from the previous date:
SQL
This query will first calculate the maximum value for each day in the
my_tabletable. It will then group the rows by date and count the number of rows for each date. TheHAVINGclause ensures that only days with a maximum value are included in the results. TheORDER BYclause sorts the results by date.The following is an example of the output of the query: