Viewing 15 posts - 1 through 15 (of 122 total)
Initial thoughts (although I fully expect the heavy hitters on this forum to come up with better suggestions i.e. my hero Jeff Moden), is that you could look at doing...
June 26, 2025 at 3:25 pm
I used temp tables so you can just see the iterations of the data. This will match your expected results.
DROP TABLE IF EXISTS #DateRanges
SELECT *,
...
June 25, 2025 at 4:29 pm
I think this is what you are looking for.
-- For each test_date, determine the last date to count in a 10 date range
; WITH DateAnalysis AS
(SELECT *,
...
June 23, 2025 at 5:03 pm
You can also use the scalar function msdb.dbo.agent_datetime:
SELECT JobName = j.name,
RunDateTime = msdb.dbo.agent_datetime(jh.run_date, jh.run_time),
...
February 11, 2025 at 5:37 pm
This should get you pointed in the right direction. Fully expect the heavy hitters to come up with some other great solutions.
-- Create a sample table
DROP TABLE...
January 9, 2025 at 5:20 pm
I have a plan. I'm learning Spanish. I'm retiring in 18 months and plan to spend a year in Europe with a base in Spain. I'm training to live...
January 3, 2025 at 4:03 pm
Scott's code is definitely more concise. Here is another method leveraging LEAD
; WITH TaskData AS
(SELECT *,
NextTask = LEAD(TaskName, 1,...
November 21, 2024 at 11:55 pm
I love a good reason to use any of the widow functions. Thank you to Kaj for some sample data. I can't tell you how many times I've had to...
November 7, 2024 at 9:19 pm
Awww man!! Keep coming west Jeff! Would love to see you make it to Orange County, CA one of these days.
August 7, 2024 at 2:28 pm
Most watched does not equate to accurate. They did have to pay out nearly $800 million due to false claims.
June 20, 2024 at 3:40 pm
Please consider learning standard SQL. We don't have an IFF() construct; that was spreadsheets and perhaps some nonrelational languages. Take the time to write everything out as a CASE...
May 2, 2024 at 3:24 pm
Couldn't it be as straightforward as this??
SELECT t.[pick your columns]
FROM SomeTable t
INNER JOIN (SELECT [ID#]
FROM...
April 3, 2024 at 3:00 pm
This is the output I get. (In fact I did a copy/paste from my post).
March 9, 2024 at 12:15 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 INT,
...
March 8, 2024 at 11:51 pm
Viewing 15 posts - 1 through 15 (of 122 total)