Viewing 15 posts - 61 through 75 (of 290 total)
declare @DaysToLookBack int = 5
select *
from [dbo].[TestTable1] a
cross apply (select count(*) Count
...
March 10, 2024 at 3:07 am
There aren't 3 values less than 88 within 5 days of (including the reference date) 2024-02-28
2024-02-28 minus 4 days is 2024-02-24.
So there are only 2 rows less than that...
March 9, 2024 at 10:09 pm
The gaps in dates shouldn't be an issue.
The data you provided isn't the data you put in your amendment of the query.
The results from the test data you provided...
March 9, 2024 at 7:03 am
Has TRADE_DATE got a time part on it? If so is it not always midnight?
Can you supply some test data?
np. here you go:
CREATE TABLE [dbo].[TestTable1](
[company] [nvarchar](50)...
March 9, 2024 at 5:47 am
declare @DaysToLookBack int = 5
select *
from [dbo].[TestTable1] a
cross apply (select COUNT(*) Count
...
March 9, 2024 at 3:54 am
This is the output I get. (In fact I did a copy/paste from my post).
my bad. i made a typo when i copied over the formula. ...
March 9, 2024 at 12:58 am
It's Friday afternoon and this was a nice small example. Here's my offering:
-- Create sample data
DROP TABLE IF EXISTS #Example
CREATE TABLE #Example
(DayNum...
March 9, 2024 at 12:10 am
Need sample data that is directly usable, that is, CREATE TABLE and INSERT statement(s), not just a splat on the screen.
no problem. here you go:
CREATE TABLE...
March 8, 2024 at 11:48 pm
You've already got restrictions based on @LOOK_BACK_PERIOD in the WHEREs, it would just be more efficient to pre-filter rather than waiting until some processing has been done on all...
March 7, 2024 at 8:52 pm
duplicate post by accident
March 7, 2024 at 8:29 pm
thank you both! i know how to fix my query now because of your feedback. thank you again for the help!!
Cool. Can you show us what you settled...
March 7, 2024 at 8:02 pm
Did you add the WHERE condition for the TXN_DATE? If you have a long history in the table, that would help the most.
Then try an index on (txn_date, company)...
March 7, 2024 at 6:49 pm
Need the DDL for the table to sure of more specific recommendations for best speed, but, assuming you will keep a long history in this table:
(1) Either:...
March 7, 2024 at 5:01 pm
Need the DDL for the table to sure of more specific recommendations for best speed, but, assuming you will keep a long history in this table:
(1) Either: (A) cluster...
March 7, 2024 at 4:05 pm
sure thing no problem.
I have attached an Excel sheet with sample data and expected outcome. In case you prefer to not download file then here is a screenshot with description. ...
March 7, 2024 at 3:36 pm
Viewing 15 posts - 61 through 75 (of 290 total)