Viewing 15 posts - 16 through 30 (of 4,033 total)
For future reference, many people are wary of opening random files from the Internet. If you want help, please post a script to create a TEMP table and insert the...
January 30, 2024 at 9:32 pm
You can't generally define aliases INSIDE expressions.
Drew
PS: You're dates don't match.
December 28, 2023 at 6:20 pm
Yes, that's a bit shorter and generally more efficient. I'm wondering if there were a lot more that 12 items per customer and the right indexes on the table...
December 26, 2023 at 3:09 pm
;WITH CTE AS
(
SELECT DISTINCT CustomerCode
FROM myTable
)
SELECT B.*
FROM CTE A
CROSS APPLY(SELECT TOP(12) *
...
December 21, 2023 at 7:25 pm
Nested CASE
expressions are very hard to read, because it quickly becomes difficult to tell exactly where you are in the nesting. Here is an example that uses a single...
December 21, 2023 at 3:40 pm
00000 is an integer, so you are explicitly converting your value to char, but then implicitly converting it back to integer when you add it to 00000. You want to...
December 5, 2023 at 7:14 pm
update #leadtest set [gamedate] = (select Lead([gamedate], 1) OVER( ORDER BY [gamedate] ASC))
LEAD is a windowed function - what makes you think it is going to...
December 5, 2023 at 4:16 pm
You're making the two most common mistakes when working with intervals.
The tendency when comparing two intervals is to compare the starting values with starting values and ending values with ending...
November 22, 2023 at 5:03 pm
@Drew.Allen - is there a reason you need an artificial column to aggregate on? Couldn't you use a COUNT on the ID, assuming there are no duplicate rows and...
November 21, 2023 at 10:24 pm
I think it's more likely that he's misstating what he wants, because he doesn't have enough knowledge, rather accurately stating that the solution should not use an aggregate. Assuming that...
November 21, 2023 at 10:19 pm
Yes, it can be done with PIVOT. You'll need to create an artificial column to aggregate on. AND you should investigate cross tabs.
Drew
November 21, 2023 at 9:53 pm
Here is a solution using your sample data. Since you didn't supply the expected results as consumable data, I didn't compare the results with the expected results.
/*...
November 10, 2023 at 4:59 pm
You're doing your calculation backward. You're calculating the duration and then dividing it up into blocks instead of dividing it up into blocks and calculating the duration in each block. ...
November 9, 2023 at 5:26 pm
Now that Jonathan has given you a solution, this likely to perform better.
WITH ShiftSummary AS
(
SELECT *, LAST_VALUE(ss.EntryDate) OVER(ORDER BY ss.EntryDate ROWS BETWEEN CURRENT...
October 18, 2023 at 6:12 pm
Presumably, the 12 records weren't all entered at exactly the same time on that date, but that is what you are checking for.
Drew
October 18, 2023 at 4:52 pm
Viewing 15 posts - 16 through 30 (of 4,033 total)