Created
September 24, 2020 12:20
-
-
Save shekhar-kamble/4a28a6cddcb89d31254a151b2923c54b to your computer and use it in GitHub Desktop.
Its creates a group monthly time series of summation of "amount" from table "required_table" according to the "created_date" of the records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM(`required_table`.`amount`) AS sum_amount, DATE_ADD(CONVERT_TZ(DATE_FORMAT(CONVERT_TZ(DATE_SUB(created_date, INTERVAL 0 second), '+00:00', 'Etc/UTC'), '%Y-%m-01 00:00:00'), 'Etc/UTC', '+00:00'), INTERVAL 0 second) AS date_add_convert_tz_date_format_convert_tz_date_sub_created_date_interval_0_second_00_00_etc_utc_y_m_01_00_00_00_etc_utc_00_00_interval_0_second FROM `required_table` GROUP BY DATE_ADD(CONVERT_TZ(DATE_FORMAT(CONVERT_TZ(DATE_SUB(created_date, INTERVAL 0 second), '+00:00', 'Etc/UTC'), '%Y-%m-01 00:00:00'), 'Etc/UTC', '+00:00'), INTERVAL 0 second) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment