Showing posts with the label Day of Week

Featured Post

SQL Query: 3 Methods for Calculating Cumulative SUM

SQL provides various constructs for calculating cumulative sums, offering flexibility and efficiency in data analysis. In this article, we explore three distinct SQL queries that facilitate the computation of cumulative sums. Each query leverages different SQL constructs to achieve the desired outcome, catering to diverse analytical needs and preferences. Using Window Functions (e.g., PostgreSQL, SQL Server, Oracle) SELECT id, value, SUM(value) OVER (ORDER BY id) AS cumulative_sum  FROM your_table; This query uses the SUM() window function with the OVER clause to calculate the cumulative sum of the value column ordered by the id column. Using Subqueries (e.g., MySQL, SQLite): SELECT, t1.value, SUM(t2.value) AS cumulative_sum FROM your_table t1 JOIN your_table t2 ON >= GROUP BY, t1.value ORDER BY; This query uses a self-join to calculate the cumulative sum. It joins the table with itself, matching rows where the id in the first table is greater than or

Python How to Find Day of the Week

DAY of the week Python code you will know here. One is from Calendar, and another one is from a function. Here, I have given my ideas on a better method. Also, the result you can get in a tuple. You might also like Attitude is Everything That Changes Your Life. Day of Week and Day_Name Monday 0 Tuesday 1 Wednesday 2 Thursday 3 Friday 4 Saturday 5 Sunday 6 Python: Day of Week How to Calculate 1. Python Logic to get Day of Week from Calendar from datetime import datetime import calendar dt = dn = dt.weekday() print ("Today is day number: {0}".format(dn)) print ("Today is a {0}".format(calendar.day_name[dn])) Here, the print uses string.format method to print output. Check out   the best example to use this method . The Output The result from the first logic Instead of directly using DateTime, you can write a function - that creates a tuple with Day of week and Day name. 2. Python Logic to get Day and Day_name  User defined function from datetime i