Viewing 15 posts - 196 through 210 (of 4,087 total)
Here is a comparison of the two methods:
/* Windowed Aggregate (MAX) */Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads...
August 4, 2022 at 7:00 pm
I just did a deep dive on that code. ANSI NULLs are the key there! Really cool code! Thanks, again, Drew. Do you have a link where Itzik provides...
August 4, 2022 at 6:39 pm
Here is a comparison of the two methods:
/* Windowed Aggregate (MAX) */
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob...
August 4, 2022 at 5:41 pm
As a side note, there is no way to implement this using just LAG()
, since 2022-07-01 can only be the immediate predecessor of one record and you would need it...
August 4, 2022 at 5:33 pm
I believe that this gives you your desired results. It's based on code by Itzik Ben-Gan. I prefer to use BINARY rather than CHAR except in the case of DATE...
August 4, 2022 at 5:25 pm
Please don't cross post. It fragments the replies. Other thread https://www.sqlservercentral.com/forums/topic/query-help-299#post-4072505
Drew
August 4, 2022 at 3:19 pm
I believe that this code is faster. It's based on code by Itzik Ben-Gan.
SELECT ID
, t.VAL
, CAST(SUBSTRING(MAX(CAST(ID...
August 4, 2022 at 2:57 pm
July 14, 2022 at 5:52 pm
First, this website is specifically dedicated to Transact SQL. You might be better off posting to a website specifically for mySQL or to a general SQL website.
Second, stating only that...
July 7, 2022 at 5:57 pm
Change your point of view. Instead of looking back to see which customers were active, spread your customers' activities forward. The following only takes one scan and one logical read.
July 5, 2022 at 3:06 pm
Thanks for the improvement Jeff. I was thinking about that after I posted and realized that it would limit it to just a year. The mod that I was going...
June 30, 2022 at 9:17 pm
This code produces the exact same results as Steve's but runs in about half the time.
WITH BusinessDates AS
(
SELECT *, COALESCE(MAX(bd.BusinessDate) OVER(PARTITION BY MONTH(c.CalDate)...
June 30, 2022 at 7:12 pm
I would use DATEADD()
instead. DATEDIFF()
and DATEPART()
use boundaries instead of full periods.
WHERE wk.appl_createddate <= DATEADD(wk,4,wk.appl_conversiondate)
AND wk.appl_conversiondate <= appl_createddate /* This may...
June 7, 2022 at 3:52 pm
Whenever you do a left join a small table and a large table make sure that large table is defined first in the join query. In your case the...
June 7, 2022 at 2:50 pm
Viewing 15 posts - 196 through 210 (of 4,087 total)