Viewing 15 posts - 31 through 45 (of 4,083 total)
The endpoints of the window can be specified as any of the following in order:
NOTE: The first endpoint must precede...
September 25, 2024 at 8:59 pm
You should always check your scripts before posting them on the Internet. You have an extra comma in your INSERT
clause. You should also make sure that others don't need...
September 25, 2024 at 5:47 pm
My guess is to copy Drew's query but with DISTINCT in the outer SELECT
Presumably, the ID field is the primary/unique key, so adding DISTINCT
will not change the results,...
September 25, 2024 at 4:36 pm
I think you need to include the leading zero, since this is a string, not an integer.
select ‘Amount’ as Amount, [0] ,[1] ,[2] ,[2] ,[3] ,[4] ,[5]...
September 25, 2024 at 4:22 pm
You didn't provide sample data and expected results.
This is my best guess:
WITH BRE AS
(
SELECT Id, WOCode, Site, Section, CompletionDate
...
September 25, 2024 at 1:33 pm
This solution gives similar results, but performs faster, because there are fewer reads.
SELECT f.createdate, f.holiday, f.holidaydate, f.holidayall, h.holiday, h.holidaydate
, MAX(h.holiday) OVER(ORDER BY...
September 18, 2024 at 6:34 pm
The STRING_SPLIT()
function was introduced in SQL 2016. It's not as powerful as the solution Johan is pointing to, but it should suffice for your purposes.
Drew
September 18, 2024 at 2:42 pm
You're missing sample data and expected results.
It looks like a partial rollup. Without sample data and expected results, I can only hazard a guess. The following should be close-ish.
September 18, 2024 at 2:36 pm
I'll guess since you didn't post a way for anyone to post tested code.
Use LEAD to access subsequent data in the current row. Then compare AgentExpDate to the LEAD...
September 6, 2024 at 3:11 pm
Do it in the other order. Use UPDATE to update the records using the OUTPUT clause to output your required fields.
Drew
August 28, 2024 at 1:31 pm
Did you try:
Select 'Restored' as source, AppUser.UserId, usergroup.Name, AppUser.UserName
from AppUser
INNER JOIN RestoredDatabase.dbo.AppUser_UserGroup
ON AppUser.UserId = AppUser_UserGroup.UserId
INNER JOIN RestoredDatabase.dbo.UserGroup
...
July 31, 2024 at 4:20 pm
This "check" field, is this something that you create as a field in a table? Because I've never seen that done.
What is the reasoning behind not using BIT flags? ...
July 1, 2024 at 2:39 pm
The fact that you're getting duplicates is an issue with your logic. You haven't given us enough information to troubleshoot the logic, but it's probably do to the fact that...
June 20, 2024 at 2:05 pm
We definitely need more information, because, as currently written, the second table is completely unnecessary.
Drew
June 20, 2024 at 1:42 pm
This gets close to what you want. It uses an ILTV function for the tally table. It essentially uses a running total modulo 2 to determine whether a certain value...
June 6, 2024 at 7:03 pm
Viewing 15 posts - 31 through 45 (of 4,083 total)
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy