Viewing 15 posts - 31 through 45 (of 4,087 total)
My primary goal is to meet the stated business requirements for the code, which I don't believe your code does. You will list the "truePct" for even a single...
October 8, 2024 at 6:04 pm
Maybe this?:
SELECT poll_id ,start_date,end_date,
candidate_name, sample_size,
(select avg(pp2.pct) from [president_polls] pp2
where pp2.state = pp.state and pp2.poll_id = pp.poll_id
...
October 8, 2024 at 3:11 pm
Here is the beginning of a solution. It uses James F. Allen's (no relation) Interval Algebra: https://en.wikipedia.org/wiki/Allen%27s_interval_algebra.
The amount used from each bin depends on the relation between the purchases...
October 3, 2024 at 8:32 pm
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
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
Viewing 15 posts - 31 through 45 (of 4,087 total)