Viewing 15 posts - 16 through 30 (of 4,075 total)
You state that, "Often, we encounter situations where we need to loop through a dataset to process or update records iteratively." However, the sample that you use can trivially be...
October 16, 2024 at 3:07 pm
This is where it would help to have sample data. There are 9 different overlapping relationships, and each usage can have multiple pieces with various instances of those 9 relationships. ...
October 16, 2024 at 2:13 pm
Did you read the response I made to your other thread? https://www.sqlservercentral.com/forums/topic/which-is-the-active-price-for-each-ingredient#post-4465061
Drew
October 10, 2024 at 1:59 pm
Please use the {;}Code
button when posting code.
October 9, 2024 at 2:45 pm
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
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
Viewing 15 posts - 16 through 30 (of 4,075 total)