Viewing 15 posts - 1 through 15 (of 4,087 total)
It looks like you are using a NULL value to represent an unknown/unspecified date. While you may not be able to change this, it's better to use a specific unlikely...
May 21, 2025 at 1:05 pm
Another thing I should point out is that Johan's code assumes that your data is "clean", that is, that there are no overlaps. Mine will handle overlaps. An easy way...
May 15, 2025 at 4:28 pm
Here is a different approach based on an article by Itzik Ben-Gan.
There are three types of intervals that you can work with:
May 15, 2025 at 4:16 pm
When you define your CTE, you have to specify the column names...
WITH cteExample (FirstName, LastName, IDNo)
AS
(
SELECT fName, LName, NotMySSN
FROM tableX
)
SELECT FirstName, LastName
FROM cteExample
WHERE IDNo > 10;
If...
April 1, 2025 at 6:02 pm
Your final select in that statement is
select contractnumber from d group by contractnumber having count(*)>1
Those added columns do not appear in that SELECT
, so they do not...
April 1, 2025 at 3:00 pm
Error - Windowed functions cannot be used in the context of another windowed function or aggregate.
SELECT ROW_NUMBER() OVER (PARTITION BY Account ORDER BY A."Account") AS "RowNo", A."Account" AS "Account", (A."Debit")...
March 26, 2025 at 2:32 pm
Do you really need to create 12 temporary tables to demonstrate the problem?
Also, you should use the {;} Code
button to format your code. It makes it much easier to...
February 18, 2025 at 5:01 pm
Photos of data are not data. If it's not worth your time to provide actual data, it's not worth my time to scrape your photos for actual data.
Drew
February 10, 2025 at 5:30 pm
I believe that this also works. I have no idea which is more efficient.
CREATE PROCEDURE ListNeedsResult
@RecordID int
AS
SET NOCOUNT ON
SELECT
Sequence,
Need
FROM
dbo.NeedsAssessment
WHERE EXISTS
(
SELECT * from Assessments
WHERE RecordID =...
January 28, 2025 at 2:30 pm
There is no way for us to help you with the minimal information that you have given. There is likely a problem with your JOIN conditions resulting in too few/many...
January 28, 2025 at 2:21 pm
Please don't cross post. It tends to fragment the discussion.
Please respond to this post https://www.sqlservercentral.com/forums/topic/count-of-total-appointments-within-30-days-of-each-appointment-date
Drew
January 9, 2025 at 4:03 pm
Sorry, sorry my apologies. I didn't catch the inconsistency. The green arrows in the image you posted only point up! Afaik that's the part I missed. Once there's an...
December 23, 2024 at 5:10 pm
Here is a slightly different approach. There is no discernable difference in the performance for the sample data. When I add a primary key on Number and StartTime, this approach...
December 6, 2024 at 5:21 pm
Another thing. In cases such as this, it's usually best to start a new post and reference the old post instead of hijacking the original post. Otherwise it can get...
December 6, 2024 at 4:44 pm
The problem is that your data is stored as closed intervals (both end-points are included in the interval) when this issue requires half-closed intervals (only one end-point is included in...
December 6, 2024 at 4:41 pm
Viewing 15 posts - 1 through 15 (of 4,087 total)