Skip to content
Advertisement

Tag: window-functions

tsql to find members not contacted in past 18 months

I have a table that has ContactNumber (Bigint), MemberNumber(bigInt) and ContactDate(date). The table has millions of records (sample data image attached). I want to get all the records where member has not been contacted for last 18 months. How do I do that using tsql? Your help is highly appreciated. Thanks. Answer You must have a Member table containing all

How do I do this without a subquery?

I need to make the same query, but without a subquery! I need to get the count of rows in which genre_id is equal to the :deletedGenreId and the org_type_id value of this line in this table is not unique Answer There is nothing wrong with sub-query. Sub-query actually can help boost performance and increase code readability if you do

MySQL Running Total By Group, Time Interval

I would like to take a table of customer orders like this: And create a table calculating a cumulative running total by week, segmenting the weeks by 7 days starting at the earliest date (2020-03-01, 2020-03-08, etc.). Something like: Thanks for the help! Answer You can use aggregation and window functions (this requires MySQL 8.0). It is easier and more

Getting values from the first row, last row, and an aggregation in MySQL Window function

For a marketing related analysis I need to provide data on the first- and last-touchpoint and of the number of total interactions with our website. A simplified version of our interaction table looks like this: Our current approach looks like this: Currently, we observe that the runtime scales approximately linear with our data, which will become infeasible to compute soon.

Advertisement